![]() | ![]() |
![]() |
|---|
Each cap can be red or green, and the colors will be assigned randomly; even ten caps of one color are possible.
Starting from the back of the line, each prisoner must announce his guess about what color his own cap is. Afterward, the ones who guessed correctly will be set free, and the ones who guessed incorrectly will be executed.
The prisoners have a chance to get together the evening before to come up
with a collective strategy for maximizing the number of survivors.
What is the best strategy?
Solution:
The main insight is that if you're one of the prisoners
and you happen to know the parity
of the number of red caps the prisoner behind you sees in front of him,
you can figure out your own cap
color: you have a red cap if and only if the number
of red caps you see in front of you has the opposite parity.
Prisoner 10 says red if he sees an even number of red caps in front of him, and green otherwise. This allows Prisoner 9 to announce the correct color of his cap. Together with knowledge of the parity of red caps Prisoner 10 sees, the prisoners in front of 9 now know the parity of the red hats that 9 sees. Knowing this allows Prisoner 8 to figure out and correctly announce the color of his own cap. Together with knowledge of the parity of red caps that 9 sees, this allows prisoners in front of 8 to figure out the parity of red caps that 8 sees, etc.
Working by induction from 9 down through 1, we see that all Prisoners 1-9 will answer correctly. (Prisoner 10 will also survive if he's lucky.)
People who got this solution: Ben Joeris (student at Fort Collins High),
Tim Ellis (undergrad), Tim O'Connor, Li Hua (grad), Ben Manvel (faculty),
Julien Gagneur (Cellzome Corporation, Heidelberg).
Many others submitted interesting schemes for saving between six and eight
prisoners.
For questions, comments or suggestions for future
challenge problems: please e-mail Ross McConnell, rmm@cs.colostate.edu.