Number the seven hat colors 0โ6. Prisoner i guesses the unique color that would make
the sum of all seven hat values equal i modulo 7. Exactly one prisoner must be correct.
Try different hat assignments Each prisoner sees the other six hats but not their own.
Actual total
Result
This strategy guarantees exactly one correct guess.
Why the winning prisoner is correct
The idea in 3 steps
โ Encode colors
Call the seven colors 0,1,2,3,4,5,6.
โก Give each prisoner a target
Prisoner i assumes the total hat sum should be
i mod 7.
โข One target must match reality
The real total has exactly one remainder among
0,โฆ,6. The prisoner assigned that remainder is correct.