Here's the optimal strategy for the 100 prisoners problem, and why it works. It's a surprisingly effective solution that gives them a much better than 1/100^50 chance of success.
The Strategy
-
The Chain: The prisoners agree beforehand to form a chain. Prisoner #1 starts by opening box #1. Whatever number they find inside, they then open the box corresponding to that number. They continue this process – opening the box with the number found in the previous box – until they find their own number (Prisoner #1's number is 1).
-
Following the Chain: Prisoner #2 starts by opening box #2. They follow the same chain-following process. They open the box with the number found in the previous box, and so on, until they find their own number (Prisoner #2's number is 2).
-
Generalization: Each prisoner i starts by opening box i and follows the chain of numbers until they find their own number.
Why This Works (and the Math)
The key to understanding why this works is to realize that the problem isn't about each prisoner finding their number independently. It's about the cycles formed by the random arrangement of numbers in the boxes.
-
Cycles: Imagine the numbers 1 to 100 are randomly shuffled and placed in the boxes. This creates a permutation. A permutation can be broken down into cycles. A cycle is a sequence of numbers where each number points to the next, and the last number points back to the first.
- Example: If box 1 contains 7, box 7 contains 42, box 42 contains 1, then 1, 7, and 42 form a cycle of length 3.
-
Success Condition: The prisoners succeed if and only if the longest cycle in the permutation is no longer than 50. Why?
- If the longest cycle is 50 or less, every prisoner can follow their chain and find their number within their 50 allowed box openings.
- If there's a cycle longer than 50, at least one prisoner in that cycle won't be able to complete the chain within 50 tries.
-
Probability Calculation: We need to calculate the probability that the longest cycle is 50 or less. It's easier to calculate the probability that the longest cycle is greater than 50 and subtract from 1.
-
Let P(n) be the probability that the longest cycle has length n.
-
The probability that there is a cycle of length k is approximately 1/k.
-
The probability that the longest cycle is greater than 50 is approximately the sum of the probabilities of cycles of length 51, 52, ..., 100. This sum is approximately: 1/51 + 1/52 + ... + 1/100 ≈ ln(100) - ln(50) ≈ ln(2) ≈ 0.693
-
Therefore, the probability that the longest cycle is 50 or less is approximately 1 - 0.693 = 0.307 or about 30.7%.
Why This is Better Than Random Guessing
-
Random Guessing: If each prisoner randomly opened 50 boxes, the probability of each prisoner finding their number would be 50/100 = 1/2. For all 100 prisoners to succeed, the probability would be (1/2)^100, which is an incredibly small number.
-
Chain Strategy: The chain strategy leverages the structure of the permutation (the cycles) to significantly increase the probability of success. It's not about luck; it's about exploiting the underlying mathematical properties of the problem.
Important Notes
- The 30.7% is an approximation. The exact calculation is more complex, but the approximation is very close.
- This strategy relies on the prisoners being able to agree on the chain-following rule before the challenge begins. No communication is allowed during the challenge itself.
- The strategy is optimal in the sense that it maximizes the probability of success given the constraints of the problem.
In summary, the chain-following strategy is a brilliant solution to the 100 prisoners problem. It transforms a seemingly impossible task into one with a surprisingly good chance of success by exploiting the cycle structure of the random permutation.