Qm

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

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

Ten prisoners and hats of ten colorsThe warden knows the chain strategy100 prisoners guessing hat colors in a lineEveryone guesses their hat at onceTwo players, two hats, one of you must be right
All questions →