We use optional analytics, advertising and affiliate technologies to
measure usage, attribute advertising and improve EverythingQuant.
You can accept or reject non-essential tracking.
You are a prisoner on an island with 99 other prisoners. The devil is keeping you there, and he tells you that the following day, you are going to play a game which will decide if you all leave the island, or all die. You will have to play the following game to escape:
All 100 prisoners will receive a hat to wear, and each hat will have a number on it between 1 and 100. There may be duplicates (or not). You can look at everyone else's number, but you cannot see your own. Each person will have 1 chance to guess their number correctly. If anybody guesses their own number correctly, everybody gets to leave the island. If nobody guesses their own number correctly, everybody dies. You have until the morning to devise a strategy, but once the game begins, you cannot communicate with the other players in any way. This includes blinking, hand gestures, and making guesses out loud to send secret messages.
What strategy will give you the best chance of winning?
Solution
The best possible strategy is a strategy that guarantees success.
Label the prisoners as
\[
0,1,2,\dots,99.
\]
Also reinterpret the hat numbers \(1,2,\dots,100\) modulo \(100\), where we treat
\[
100 \equiv 0 \pmod{100}.
\]
So every hat number is now one of the residues
\[
0,1,2,\dots,99.
\]
Now fix the following rule in advance:
Prisoner \(i\) will guess the unique number that makes the total sum of all \(100\) hat numbers congruent to \(i \pmod{100}\).
Suppose prisoner \(i\) sees the other \(99\) hats, and their sum is
\[
S_i \pmod{100}.
\]
Then prisoner \(i\) guesses the number
\[
g_i \equiv i - S_i \pmod{100}.
\]
In ordinary hat labels, if \(g_i \equiv 0 \pmod{100}\), he guesses \(100\); otherwise he guesses the number \(g_i\).
Why does this work?
Let the actual total sum of all \(100\) hat numbers be
\[
T \pmod{100}.
\]
There is exactly one prisoner whose label is \(T\), namely prisoner \(T\).
That prisoner guesses his own number correctly, because he sees the other hats summing to
\[
T - h_T \pmod{100},
\]
where \(h_T\) is his actual hat number. So his rule tells him to guess
\[
g_T \equiv T - (T - h_T) \equiv h_T \pmod{100}.
\]
So prisoner \(T\) is correct.
For every other prisoner \(i \neq T\), his guess is the number that would make the total sum equal to \(i\), not to the true total \(T\), so he is wrong.
Thus exactly one prisoner guesses correctly.
Since the rule of the game only requires that at least one person be correct, everyone escapes.