Saving 99 of 100 prisoners with hat parity
Question
One hundred prisoners stand in a line, each wearing a red or blue hat. Every prisoner can see all hats except their own. In order, each one calls out a guess of their own hat colour, and everyone hears every guess. Those who guess right are freed. They may agree on a plan beforehand. What strategy saves the most prisoners for certain? How does it extend if hats can be one of three colours?
Short answer
are guaranteed in both cases. The first speaker announces the parity of the red hats they see (e.g. "red" for odd); each later prisoner compares that with the reds they see and hear named, and deduces their own colour. With three colours, code them and have the first speaker announce the sum of the hats they see modulo .
Adapted from Zhou, A Practical Guide to Quantitative Finance Interviews, sec. 2.7 Modular Arithmetic, 'Prisoner problem', p.23; question and answer rewritten by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solutionLessons behind this question
- Optimisation Problems
- Constrained Optimisation and Lagrange Multipliers
- Sample Spaces, Events, and the Probability Axioms
Start with a free lesson: Probability Fundamentals is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.
Read it free