# Four prisoners wearing black and white hats

There are four prisoners. All four prisoners will be freed, if at least one of them correctly guesses the color of the hat on his head.

They can't speak to each other, and they can't touch each other.

Number 1 sees number 2 and 3's hats.
Number 2 sees number 3's hat.
Number 3 sees only the wall.
Number 4 sees only the wall.

There are no mirrors.

They all know that there are 2 black hats and 2 white hats, and that there are four people.

They know their placement in this room is as follows:

Can the four prisoners be freed? If so, how?

• Do they get to discuss this beforehand? Why not just all say "white" (or all "black")? – Kevin Apr 11 '15 at 19:31
• Do the prisoners know the configuration of the other prisoners? 2 cannot use the silence of 1 as extra information unless 2 knows which way 1 is facing. – Eamonn McEvoy Sep 5 '18 at 14:12

4 can't see the other three due to the wall so he can't guess. 3 also can't see due to the wall. I eliminate 4 and 3. For 2, he knows 3 is wearing white hat. But how could he knows he is wearing black? For 1, if 2 hat is white then 1 hat is black. But if 1's is black and 2's is white then, he would be able to know. If the two in front have white hats then, he will answer first and say 'Mine is black'. But properly, 2 is aware of 1's hesitation , 'Ah~ 1 is also white'.Then, 2 will answer 'Mine is black'. So the answer is 2.

• Welcome to Puzzling! (Take the Tour!) How does your answer add to the many others already given? You should always look at existing answers before providing one of your own, to ensure you are not just adding what is essentially another duplicate. – Rubio Jun 1 '17 at 13:53
• @Rubio accepted with no votes ... weird ... – Rand al'Thor Jan 21 '18 at 15:45
• @Randal'Thor Very weird indeed, especially since this is objectively a worse answer than the others, of Which I can confirm 2 of them say exactly this but better worded, and they also say more about the other possible configurations. – Ryan Feb 23 '18 at 20:53
• Nothing in the question suggests they can hear each others answers. In fact, given that they can't speak to each other, this would suggest that they have to answer silently, e.g. by writing their answer down and passing it to the jailer. – AndyT Sep 5 '18 at 9:50

There are only 6 possible configuration of hats.

wwbb wbwb bwwb wbbw bwbw bbww

If $h(3)=h(2)$ then $1$ knows his. This eliminates 2 configurations (wbbw,bwwb).

And

When $2$ looks at $3$ and $1$ says nothing, then he knows his hat color is not the same as $3$. He, therefore, knows he has the opposite color as $3$ and says it accordingly.

This would be a better question if you specify that every player is killed if he guesses wrong (my answer) or they must all answer at the same time ($1$ and $2$ always guesses opposite of $3$).

• I've always heard of the first formulation, that they're all killed if one of them guesses wrong. – Joe Z. Jul 30 '14 at 1:41
• There are other hat wearing problems with the second rule on this site. The famous problem that this is a version of is the first way so that is why I answered it that way. – kaine Jul 30 '14 at 2:07

Prisoner 2 can know the color of his hat - it should be exactly opposite of that worn by the prisoner ahead of him, Prisoner 3.

Prisoner 1 can see both 2 and 3 in front of him, but the fact that he cannot guess the color of his own hat must mean 2 and 3 are wearing different colored hats. For example, if 2 and 3 both had white hats, and knowing that there are only two white hats (with the other two being black), prisoner 1 would have been able to work out that he's wearing a black hat. Likewise, if both 2 and 3 had black hats on, 1 would know he's wearing a white hat. BUT, if 2 and 3 had different colored hats on, then 1 cannot logically deduce the color of his own hat.

FROM THAT LOGIC ABOVE, 2 knows that the color of his own hat is different to the color worn by the person ahead of him (prisoner 3). Thus, if 3 has a white hat on, 2's own hat must be black. Else, if 3 has a black hat, then 2 must be wearing a white hat.

As only one person needs to deduce the answer correctly for them all to be released, that person is 2.

The other answers assume that the second person uses the first person's silence as additional information. But what if they are all required to answer at the same time? Or do so in a predefined order? Or do so without anyone else knowing?

Then there is still a solution.

• Person 2 will always assume he has the opposite of person 3 and say it.
• If 2 and 3 are the same, then person 1 will say the opposite colour since there can only ever be 2 of the same colour. Otherwise, a random colour.
• 3/4 will say a random colour.

It is guaranteed that at least one of person 1 or person 2 will be correct. If person 1 is wrong, then 2 and 3 must have different colours. But person 2 would have said the opposite colour of 3, so person 2 would be correct.

• you are right. It is allowed to give wrong answers. But why do you write so complicate: random answers make now sense, eliminate it. 1 and 2 simply say both the opposite of 3's color. Thats all. – miracle173 Oct 7 '15 at 16:09
• @miracle173 Hmm... Much cleaner solution. – Trenin Oct 7 '15 at 16:25

2 is looking at a white hat so he knows 1 would declare he was wearing a black hat if 2 were wearing white (and there would be no other options). Since he doesn't, 2 knows he must be wearing black.

• This seems like the simplest answer, yet it was downvoted. IMHO, this is the correct answer. – Trenin Mar 30 '16 at 11:58

The answer would be number two, assuming that the prisoners cannot turn around, switch places or talk beforehand. Number three and four are eliminated from guessing because they can only see the wall. That would only leave the numbers one and two to guess.

Number one is not the answer because although he/she can see both two and three's hat, the two hats are different. Number two is black and number three is white. So number one would have a 50% chance of getting the correct answer but it also means that he/she has the same chance of getting it wrong. If both numbers two and three were either both black or white, number one would know the colour of his/her hat but numbers two and three have the opposite colours, leaving number one unable to figure out what colour he/she is.

This leaves number two. Number two is the correct answer because he/she knows that there is a person behind them and in front of them as stated above in the question "They know their placement in this room is as follows." Number two knows that number three is wearing a white hat. Number two should be able to realize that the number on his head is black because if he/she had a hat that matched number three then number one should have been able to answer what colour he/she had very easily. Number two senses the hesitation of number one and knows that their hat is the opposite of number three, which means two has a black hat.

• Maybe do a bit of editing on grammar... But good – AJL Jun 4 '15 at 22:32
• "Number three and four are eliminated from guessing because they can only see the wall" That is not a valid argument. Why isn't number 2wo excluded because he can see only one hat? – miracle173 Oct 7 '15 at 15:56

The answer is simple. If you can't see anyone, pick randomly but in the end your guess don't matter.

If you can see someone, then pick the opposite color of the person directly in front of you. This is the highest probability for 2 and if 1 does the same you get the answer no matter what.

• This is the only correct answer. Most of the others rely on prisoners hearing each other, which is forbidden in the rules. If everyone in the puzzle (mainly 1 and 2, but 3 and 4 might happen to guess correctly) follow these rules, then 1 would guess correctly for wbwb bwwb wbbw bwbw, and 2 would guess correctly for wwbb and bbww (and wbwb and bwbw, but 1 already saved him in those scenarios). – NH. Jun 1 '17 at 13:49
• Number 1 thinks, that if both he and number 2 tell that their hat has the color different to number 3's hat color, then either he or number 2 is right, (see this answer). So he say that he has a black hat.

• Number 2 thinks that if number 1 will give an answer, then he does this because he see two heads with the same color (see this answer. Therefore he assumes that his hat has the same color as 3's hat says that his hat is white.

• Number 3 errorneously thinks that he cannot know anything because he stares at a wall (see this answer) so he chooses a color by random.

• Number 4 knows that if three people choose the same color at most two can be wrong and chooses the same color as number three.

So if number 3 choosed white he choosed the right color. If he choosed black then number 4 will choose black too, and number 4 will be right.

There is a strategy for number 3, too. He can assume that at least one of 1 or 2 has guessed the right color. This is possible if both 1 and 2 think in the way 2 actally does. It is not possible that 2 thinks in the way 1 actually does because 2 says a different color than 1. Number three should assume both 1 and 2 guessed the wrong color. Then it is imortant to guess the right color ( it is not really important because 4 can save them all). So he shoulkd assume that they did think wrong as they actually did. So he should select the color different to the color selected by 1 and the same color chisen by 2. So he should choose white.

C calls out that he is wearing a black hat. Why is he 100% certain of the color of his hat? After a while, C comes to the realization that he must answer. This is because D can't answer, and neither can A or B. D can see C and B, but can't determine his own hat color. B can't see anyone and also can't determine his own hat color. A is in the same situation as B, where he can't see anyone and can't determine his own hat color. Since A, B, and D are silent, that leaves C. C knows he is wearing a black hat because if D saw that both B and C were wearing white hats, then he would have answered. But since D is silent, C knows that he must be wearing a black hat as he can see that B is wearing a white hat.

• Welcome to Puzzling! This question has already been solved, as you can see by the answer towards the top with a green checkmark. – Deusovi Nov 30 '15 at 5:08

If 2 & 3 were to wear the same colour of hat, 1 will directly know what the colour of his hat is and answer it very quickly. But as 1 didn't answer it, 2 may notice that 1 did not know what the colour of his hat is. Therefore, 2 will understand that his hat and 3's hat have different colour. So that 2 can answer the answer correctly:)

It has something to do with number 1, because number 2 knows that if number 2 and number 3 has the same coloured hat, number 1 would have said something.

Because of his silence, number 2 knows that he must be different from number 3. Then number 2 can answer.

• Welcome to Puzzling! Why don't you take the site tour while you're here? This also seems to be pretty similar to some other solutions, would you care to explain how it is different? Thanks! – boboquack Mar 4 '17 at 5:00

Assuming that the prisoners can all switch places at will, all that has to happen is person 1 and 3 switch places so that person two then knows that person 1 and 3 both have white hats. Therefore person 2 can deduce that he and person 4 both have black hats on.

You guys are forgetting the rules. It says that they CAN'T speak. And it is not reasonable to assume that person 2 must know because person 1 does not say anything. But it does not say that the prisoners cannot move. It only says that they cannot SPEAK.

Actually the other posters are correct, but the instructions do not say that the prisoners can only speak if they are correct or that they cannot move. So by number one not speaking it does not necessarily mean that number one does not know, but it's logical conclusion. but it still stands that the instructions do not prohibit number one and two from switching places and this would offer undeniable proof to number two, with the least number of moves.

## protected by Rubio♦Apr 19 at 4:07

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).