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?
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.
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.
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:
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:
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:
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.