Puzzle #15: Prisoners and Hats Puzzle | Google

Four prisoners are arrested for a crime, but the jail is full and the jailer has nowhere to put them. He eventually comes up with the solution of giving them a puzzle so if they succeed they can go free but if they fail they are executed.

The jailer puts three of the men sitting in a line. The fourth man is put behind a screen (or in a separate room). He gives all four men party hats. The jailer explains that there are two black and two white hats; that each prisoner is wearing one of the hats; and that each of the prisoners is only to see the hats in front of them but not on themselves or behind. The fourth man behind the screen can’t see or be seen by any other prisoner. No communication between the prisoners is allowed.

If any prisoner can figure out and say to the jailer what color hat he has on his head all four prisoners go free. If any prisoner suggests an incorrect answer, all four prisoners are executed. The puzzle is to find how the prisoners can escape, regardless of how the jailer distributes the hats.

Puzzle Solution:

Prisoner C and D are in the same situation – they have no information to help them determine their hat color so they can’t answer. A and B realize this.

Prisoner A can see both B and C’s hats. If B and C had the same color hat then this would let A know that he must have the other color.

When the time is nearly up, or maybe before, B realizes that A isn’t going to answer because he can’t. B realizes that his hat must be different to C’s otherwise A would have answered.

B therefore concludes that he has a White hat because he can see C’s Black one.

#PrisonersandHatsPuzzle #InterviewPuzzle #Puzzle #GoogleInterviewPuzzle