# A logic problem. No need for calculation

Three people were told to go to a cave and each pick up a hat in pitch dark. The three then came out of the cave with the hat on their heads. There were five hats in the cave. Three of them are black, the rest is white. When the first one is asked to tell the color of his hat, he said that he doesn't know. The second person told then same. But the third person said he knows. Why does he know the color of his hat based on what he heard from the other two persons? And how?

-
I first saw this problem (with different narrative) in "The Man Who Counted" by Malba Tahan (pseudonym of Júlio César de Mello e Souza). An amazing book of puzzles with delightful stories, great for the young mind and adults alike. It has wide distribution in Latin America, but is mostly unknown in the US. I wonder if it's frowned upon in the US because it's viewed as promoting religion (Muslim); it doesn't, not by a long shot. – Euro Micelli Apr 27 '14 at 5:25

Initially there are 7 possibilities:

 1 | 2 | 3
===|===|===
B | B | B
B | B | W
B | W | B
B | W | W
W | B | B
W | B | W
W | W | B


First says that he doesn't know, so one of 2-3 has a black, that leaves us with:

 1 | 2 | 3
===|===|===
B | B | B
B | B | W
B | W | B
W | B | B
W | B | W
W | W | B


Second says he doesn't know, that means one of the others has a black, which leaves us with:

 1 | 2 | 3
===|===|===
B | B | B
B | B | W
B | W | B
W | B | B
W | W | B


Moreover, the second knows that the first has seen a black among 2 or 3 and he sees that 3 has white in row 2, so if row two is the case then the second actually does know his color, so row 2 gets eliminated:

 1 | 2 | 3
===|===|===
B | B | B
B | W | B
W | B | B
W | W | B


The third knows that his color is black, because in all remaining worlds that's the case.

-
What if the second person is blind? – user11355 Apr 28 '14 at 22:16
Then wouldn't there be two different cases? Since he always say idk. – user11355 Apr 28 '14 at 22:17
That changes the problem. Since person 2 is blind, his announcements don't update the epistemic state at all. So the situation reduces to this. Person 1 says 'idk' means that at least one of 2 or 3 is wearing black. Person 3 cannot know whether the person wearing black is him or person 2. There isn't enough information to eliminate possibilities. – Hunan Rostomyan Apr 28 '14 at 22:27
It is now one of the possibilities for a total of five – user11355 Apr 28 '14 at 23:43
Should be six (the two new possibilities being: BBW and WBW). – Hunan Rostomyan Apr 28 '14 at 23:51

Person 1 states that he does not see 2 white hats.

If Person 2 sees a white hat on person 3, then he knows that his hat is black, because there must be at least 1 black hat between 2&3.

So Person 2 must have seen a black hat on person 3, leading to his uncertainty.

-
+1 This is great. Doesn't get simpler. – Hunan Rostomyan Apr 27 '14 at 2:09
I guess it depends on your definition of simple. Short isn't the same as simple. In my opinion, mine is the "epiphany solution", and the straightforward enumeration of states answers of the other posters is simpler. For someone learning to solve this kind of problem, the other answers are probably better learning tools than mine. But thanks for the vote ^_^ – DanielV Apr 27 '14 at 3:55
I think it should be noted that not only does the third person know his hat is black, so do we who have seen nothing. In particular the third person did not have to see the other two, just to be seen by them. I think the story could be somehow improved to make this aspect come out better. – Marc van Leeuwen Apr 27 '14 at 16:48
We who has seen nothing, ? – user11355 Apr 27 '14 at 17:25
After the announcements of persons 1 and 2, [that person 3 has a black hat] becomes common knowledge. Neither we nor person 3 has to see anything because the epistemic space is such that all possibilities have person 3 wearing a black hat. I'd work Marc's wonderful suggestion into the question by adding the condition: person 3 is blind (and still says that he knows). – Hunan Rostomyan Apr 27 '14 at 18:35

Probably each person can see the hats of the other 2 persons. Let A,B,C denote the 3 persons. A says he doesn't know so B,C don't both wear white hats otherwise he would know that he wears a black one. So B,C wear both black or one black and one white. Same stands for B. So A,C wear both black or one black and one white. So we have the 6 cases of what each of the 3 can be wearing:

A: |x|x|x|B|B|W|
B: |B|B|W|B|W|B|
C: |B|W|B|x|x|x|


So C sees what A,B wear according to the above table (checking the right half of the table). For example if B wears white hat then C wears black hat.

So we obtain the following according to the above observations:

A: |  B   |B|W|
B: |  B   |W|B|
C: |B or W|B|B|


But in the first column C cannot wear white since then B by seeing that C wears white and that not both B,C wear white (because A doesn't know what he wears) then he would know that he wears black. So we exclude this possibility and we have:

A: |B|B|W|
B: |B|W|B|
C: |B|B|B|


So C wears a black hat.

-

If first person saw the two others wearing white hats, he would know that he must wear a black hat, and would have said "black". Since he said he doesn't know, at least one of the other two must wear a black hat.

The second person can look at the third. If the third is white, he knows that he himself is black (based on the first guy's answer), and must answer "black". Since he says he doesn't know, the third person must be wearing a black hat.

-