Qm

Four prisoners, four hats and a wall

Four prisoners are given hats: two black and two white. They know this. They are arranged as follows and cannot move or turn:

  • Prisoner A stands at the back and can see prisoners B and C in front of him.
  • Prisoner B stands in the middle and can see only prisoner C.
  • Prisoner C stands at the front, facing a wall, and sees nobody.
  • Prisoner D stands on the other side of the wall and sees nobody, and nobody sees him.

The hats, from back to front, are: A black, B black, C white, D white. Nobody may speak except to call out their own hat colour, and the first correct call frees all four; a wrong call condemns them. They can all hear.

Who calls out, what does he say, and how does he know?

Show a hint

A sees two hats. Why does he stay silent? What does his silence tell B?

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

Three wise men, five hats, and the blind one knowsThree mislabeled fruit jarsThree prisoners and colored hats in a lineTold that the number of red hats is oddWho owns the zebra?Hat guessing with the option to pass
All questions →