100 Prisoners, 50 Boxes Each, and a Strategy That Survives 31% of the Time
Independent guessing gives the prisoners 7.9 x 10^-31. Following the slip you just found gives them 0.311828, and the gap is thirty orders of magnitude from a rule you can state in one sentence. The strategy never raises anyone's individual chance above one half; it only makes the failures coincide, which is the whole lesson.
A hundred prisoners are numbered 1 to 100. In a room stand a hundred closed boxes, and inside them, in some order nobody knows, are slips carrying the same hundred numbers. One at a time, each prisoner enters, opens any fifty boxes of their choosing, and looks for their own number. Then the boxes are shut and the room is restored.
They may agree on a plan beforehand. Once the first one walks in, no signal of any kind is possible. If every single prisoner finds their number, all go free. If one fails, all hundred are executed.
The obvious verdict is that this is theatre. Fifty boxes out of a hundred is a coin flip each, so a hundred coin flips have to come up heads:
There is a strategy that gets them to . Not a slightly better number. Thirty orders of magnitude better, from a rule you can explain in one sentence.
Follow the slip you just found
Prisoner opens box first. Inside is a slip with some number on it. Open that box next. Read the slip, open that box, and keep going for up to fifty openings.
That is the whole plan. No one chooses anything, no one needs to remember anything, and yet it works.
A permutation is a handful of loops
The slips define a permutation : box contains the number . Chasing slips from box walks the sequence , and since a permutation of a finite set is invertible, that walk cannot wander off or branch. It comes back to where it started. Every permutation splits into disjoint cycles, and the walk traces the one containing .
The number the prisoner wants is itself, and the box holding it is the box that points back to the start, the last stop on the loop. So prisoner succeeds exactly when their cycle has length at most fifty. No approximation is involved.
Everyone survives if and only if the permutation has no cycle longer than 50. One fifty-one-cycle and every prisoner on it fails together; everyone else was never at risk. A hundred separate questions collapsed into one question about one object.
Counting the permutations that kill them
A permutation of 100 elements can hold at most one cycle longer than 50, since two would need more than a hundred elements between them. Long cycles are therefore mutually exclusive, and the failure probability is a plain sum with no inclusion-exclusion to untangle.
Count the permutations with a cycle of length exactly : choose which elements sit on it, arrange them into a cycle in ways, and permute the remaining freely.
The factorials cancel completely, which is the small miracle that makes this problem quotable. Summing over the fatal lengths:
Roughly one run in three. The prisoners are still likely to die, and the interviewer is not asking you to be optimistic. They are asking whether you notice that and can describe the same hundred people.
Why the number barely depends on the hundred
Replace 100 by and the allowance by . The same argument gives , and since , the constants and the cancel:
A million prisoners opening half a million boxes each survive with probability , essentially the same as a hundred. The ratio of what you are allowed to what exists is the only input, and everything else washes out.
What the strategy actually bought
This is the part worth carrying out of the room, and it is not the arithmetic.
Under the cycle rule, ask how likely a single named prisoner is to find their number. The cycle containing a fixed element is equally likely to have any length from 1 to 100, each with probability , so the answer is fifty hundredths:
Exactly the same as random guessing. The strategy does not make anybody luckier, and no strategy could. What it changes is how the failures are arranged. Independent flips scatter them, so at least one lands almost surely. The cycle rule welds all hundred outcomes to a single feature of a single permutation, and welded outcomes either all hold or all break.
A portfolio person has met this already, wearing the other sign. Identical marginals, different dependence, and the distribution of the total moves enormously while every individual probability stays put. It is why a thousand independent bets behave so unlike a thousand correlated ones, and why a tranche can be rated on marginal default rates and still be worthless. Correlation was never a detail of the model. Here it is worth a factor of .
Sources and further reading
- A. Gál and P. B. Miltersen, “The cell probe complexity of succinct data structures”, ICALP 2003 — where the puzzle first appears, as a lemma inside a data-structure lower bound
- E. Curtin and M. Warshauer, “The locker puzzle”, The Mathematical Intelligencer 28 (2006), 28–31 — the proof that no strategy beats 1 − ln 2 in the limit
- 100 prisoners problem — the statement, the cycle argument and the usual variants
- Random permutation statistics — where the 1/k law for the longest cycle comes from
Comments · 0
Be the first to comment.