Hats in a line when nobody can hear
A hundred prisoners stand in a line. Each wears a red or blue hat, chosen by the warden. Each prisoner can see every hat in front of them, but not their own and not the ones behind. Starting from the back, each prisoner whispers a guess of their own hat colour to a guard. Nobody can hear anyone else's guess, and the guard gives no reaction.
The prisoners may agree a strategy beforehand. The warden knows the strategy and chooses the hats.
What is the largest number of prisoners that any strategy can guarantee to save? Then: if instead the hats are assigned by fair coin flips, how many survive on average?
Show a hint
Try to build a strategy that guarantees even one prisoner. Then think about what the warden can do once she knows the strategy.
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
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.