A Police officer caught four criminals. He plays a game with these four men. He lines up three of the prisoners (A, B, C) in one room and the fourth prisoner(D) is placed in a separate room.

Each prisoner is given a hat to wear. The officer tells them that there are in total two blue hats and two red hats. If any of them can guess the color of the hat they are wearing right, he promises to set all four of them free. They cannot communicate with each other, the only information is that

- The prisoner A can see the colors of hats worn by prisoner B and prisoner C.
- Prisoner B can ONLY see the color of hat worn by prisoner C.

After a few minutes of silence, one of the prisoner gets the answer right, who is it?

**Solution:** Prisoner B gets the answer right.

**Explanation:** Based on the arrangement made by the officer, the only thing that prisoner B can see is prisoner C wearing a blue hat. Prisoner B has no information about the other two prisoner’s hat colors.

Then he calculates,

- He can be wearing either a blue hat or a red hat.
- If he is wearing a blue hat, prisoner A should be seeing a blue hat on him (prisoner B) and a blue hat on prisoner C and therefore the remaining two are red hats, he must have declared his answer way before without any thinking, but he is silent. This means that he (prisoner B) is not wearing a blue hat. Hence he figures out that he is wearing a red hat.

This puzzle is contributed by **Harika Mulmudi.** Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.