This is a classic probability and strategy puzzle known as the "100 prisoners problem". The surprising result is that there is a strategy that gives the prisoners a much higher chance of success than random guessing.
The Problem Recap:
- 100 prisoners.
- 100 boxes, each containing a unique number from 1 to 100 (each number appears exactly once).
- Each prisoner can open up to 50 boxes.
- If every prisoner finds their own number, they all go free.
- If even one prisoner fails, they all stay imprisoned.
- Prisoners can agree on a strategy beforehand, but cannot communicate during the process.
Naive Strategy (Random Guessing):
If each prisoner opens 50 random boxes, the chance that a single prisoner finds their number is 50%. The chance that all 100 prisoners succeed is:
[
(0.5)^{100} \approx 7.9 \times 10^{-31}
]
This is effectively zero.
Optimal Strategy: The Cycle-Following Strategy
This strategy is based on the structure of permutations and cycles.
The Strategy:
- Each prisoner starts by opening the box labeled with their own number.
- Inside that box is a number — say prisoner 1 opens box 1 and finds number 45.
- The prisoner then opens box 45.
- Suppose box 45 contains number 72. The prisoner then opens box 72.
- This continues until the prisoner either:
- Finds their own number (success), or
- Opens 50 boxes without finding it (failure).
Each prisoner follows the chain of numbers starting from their own number.
Why This Works:
- The contents of the boxes form a random permutation of the numbers 1 to 100.
- Any permutation can be broken down into disjoint cycles.
- The prisoner following the chain is essentially traversing the cycle that contains their number.
- If all cycles in the permutation are of length ≤ 50, then every prisoner will find their number within 50 steps.
- If any cycle is longer than 50, then the prisoner whose number is in that cycle will fail.
So, the success of the strategy depends on the maximum cycle length in the random permutation.
Probability of Success:
The probability that a random permutation of 100 elements has no cycle longer than 50 is approximately:
[
\approx 31%
]
This is vastly better than the near-zero chance from random guessing.
Conclusion:
The best strategy is:
Each prisoner starts by opening the box labeled with their own number, then opens the box labeled with the number found inside, and continues this process up to 50 times.
This strategy gives the group about a 31% chance of success, which is the best known strategy for this problem.
Bonus Insight:
This problem beautifully illustrates how understanding the structure of permutations and cycles can lead to counterintuitive but powerful strategies.