Three hat guessers
Three people each wear a hat colored red, yellow, or blue (repeats allowed, e.g. YYB, RYB, RRR…). Each person sees only the other two hats, not their own.
All three simultaneously state a guess for their own hat color. No communication during the game, but they may agree on a strategy beforehand.
Can they design a strategy so that no matter how the hats are placed, at least one person is guaranteed to guess correctly?
Yes. Here is the three-person version, then the general n-person rule.
Numbering
Map red, yellow, blue to 0, 1, 2. Label the people 0, 1, 2 (fixed order agreed in advance).
Let hᵢ be the number on person i’s hat (i = 0, 1, 2).
Strategy (three people)
Person i guesses:
gᵢ = ( i − sum of the others’ hat numbers ) mod 3
Explicitly:
- Person 0: (0 − h₁ − h₂) mod 3
- Person 1: (1 − h₀ − h₂) mod 3
- Person 2: (2 − h₀ − h₁) mod 3
Why at least one guess is always correct
Let S = h₀ + h₁ + h₂.
- If S ≡ 0 (mod 3): person 0’s guess equals h₀ → person 0 is correct.
- If S ≡ 1 (mod 3): person 1’s guess equals h₁ → person 1 is correct.
- If S ≡ 2 (mod 3): person 2’s guess equals h₂ → person 2 is correct.
One residue class always holds, so at least one person is right for every hat assignment.
Generalization: n people, n colors
With n people and hat colors numbered 0, 1, …, n−1 (repeats allowed), person i (i = 0, …, n−1) guesses:
gᵢ = ( i − ∑_{j≠i} hⱼ ) mod n
The person whose index equals S mod n is guaranteed to be correct. So for any n, the strategy ensures at least one correct guess (in fact, exactly one in the mod-n sense).
Takeaway
The trick is not luck: the sum of hat numbers mod n determines which index must guess correctly, and the formula routes that responsibility to the right person.