You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Because there is only one possibility where 3 people are correct according to the
-- teacher the boy with 3 accusers will be found guilty. So we check for each person how
-- many accusers he has untill we find the one with 3 accusers.
checkGuilty :: Boy -> [Boy] -> [Boy]
checkGuilty x xs = if length (accusers x) == 3 then [x]
else checkGuilty (head xs) (tail xs)
The remark if the puzzle is well-designed... is not an assumption. So checkGuilty must be changed in:
checkGuilty :: Boy -> [Boy] -> [Boy]
checkGuilty x [] = []
checkGuilty x xs = if length (accusers x) == 3 then [x]++checkGuilty (head xs) (tail xs)
else checkGuilty (head xs) (tail xs)
The remark if the puzzle is well-designed... is not an assumption. So checkGuilty must be changed in:
Simpler interface will be:
Well done!
The text was updated successfully, but these errors were encountered: