# 3 Prisoners and Some Hats

### Problem:

In a remote prison somewhere in the Pacific Ocean, three prisoners are serving a life sentence. The guards get bored and decide to play a game with the inmates to pass time.

They have a bag of hats, and they show the prisoners there are five hats in the bag, three black hats and two white hats. The guards make the prisoners sit in chairs and line them up in a row, such that the prisoner in the back of the line can see the two in front of him, the prisoner in the middle can see the one person in front of him, and the prisoner in the front can see nothing but a prison wall.

The guards blindfold the prisoners and place a hat on each of their heads. They then remove their blindfolds and tell the inmates that they can go free if they correctly name the color of the hat they have on, but if they guess wrong, they will be shot dead. In addition, the prisoners cannot see what color hat they have on their own head.

The guards first ask the prisoner in the back of the line, "what color hat do you have on?" He says he doesn't know. They ask the man in the middle, and he also doesn't know. When the guards ask the prisoner in the front of the line what color hat he has on, he answers correctly, and goes free.

**What color hat did he have on, and how did he know?**

### Hint:

Pretend that you are the prisoner in the back of the line. What do you see? Then pretend you are the prisoner in the middle of the line. You need to use information gleaned by the fact that the first two prisoners do not know what color hat they have on. It is a process of deduction beginning with the first prisoner, so once you understand what he sees, move on to the second prisoner and continue that train of logic.

### Solution:

**What color was he wearing? Click here to reveal.**

#### Black

Here is how he managed to be set free.

Start with the first prisoner to respond. He's sitting in the back of the line where he can see the two prisoners in front of him, and he doesn't know what color hat he has on. There are three black hats and only two white hats, so if he had seen white hats on both prisoners in front of him, he would have known that he had a black hat on. Therefore, we can conclude he does not see two white hats in front of him.

The fact that the first prisoner couldn't solve the riddle tells the second prisoner, in the middle of the line, something important: He and the man in front of him cannot both be wearing white hats. That leaves three options.

A) Both he and the man in front are wearing black hats

B) The man in front is wearing a white hat, while he is wearing a black one

C) The man in front is wearing a black hat, while he is wearing a white one

If the man in the middle had seen the man in front wearing a white hat, he would have known that choice B is the correct one, announced that he was wearing a black hat, and walked free. Because he doesn't figure out what color hat he has on, we know that he must see a black hat in front of him, as that would leave open the possibility that he was wearing either color (choice A and C are both possibilities).

Now consider the three choices from the perspective of the man in the front. He doesn't know which of the remaining choices, A or C, is the correct one. But in either scenario, he must be wearing a black hat. He manages to be set free, while the other two remain in the cell.