Seven Prisoners โ€” Guaranteed Hat Strategy

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.