Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab1: Exercise 8 #1

Open
BertLisser opened this issue Sep 14, 2017 · 1 comment
Open

Lab1: Exercise 8 #1

BertLisser opened this issue Sep 14, 2017 · 1 comment

Comments

@BertLisser
Copy link

{--
accusesAll: A reuseable function that checks if a boy accuses all the boys in
the given list.
--}
accusesAll :: Boy -> [Boy] -> Bool
accusesAll x l = all (\b -> accuses x b) l

{--
Plus the list of boys who made honest (true) statements:
Result: [Matthew,Peter,Carl]
--}
honest :: [Boy]
honest = filter (\b -> accusesAll b guilty ) boys

Nice solution. The question which is left open:
Suppose a boy who accuses all the boys. Is he a honest boy? He certainly makes honest declarations.
The specification is not clear about this.

Well done!

@piotrkosytorz
Copy link
Contributor

Dear Bart,

Thank you.

After processing the input data, we've build a grid based on logical statements given in the exercise:
img_1532_jpg

As it is can be seen on the photograph, from the logical point of view, a boy who accuses everybody from the "guilty" list should be considered an honest person (Mathew, Peter, Carl), because by the conditions of the exercise, there are 3 boys who are always telling the truth. Therefore the two boys who don't accuse the guilty one(s), should be considered liars (Jack, Arnold).

By this logic, a boy who accuses everyone should be on the list of honest boys, because he is telling the truth about the guilty ones.
This is also directly stated in our solution:

honest :: [Boy]
honest = filter (\b -> accusesAll b guilty ) boys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants