Thought Toys · Games & choices · Exhibit 133
A hundred boxes, labelled 1 to 100, hold those same hundred numbers inside them in some unknown order. Each prisoner may open fifty and must find their own number, and they all go free only if every one of them does. Guessing gives them less than one chance in a nonillion. They can agree one rule beforehand, and it gives them thirty-one per cent.
The boxes, coloured by the chain each one belongs to ● the longest chain ● too long — the room loses ● the chain being walked
—
—
The rule is one sentence. Open the box whose label is your own number. Whatever number you find inside it, go to the box carrying that label next. Keep following.
That is all. No cleverness, no signals, nothing left to decide. And it multiplies their chances by four hundred thousand million million million million — almost thirty orders of magnitude.
Here is why. The boxes are a shuffle, and every shuffle breaks into closed chains: box 7 holds 31, box 31 holds 2, box 2 holds 7, and the chain shuts. The grid above is tinted by chain.
Start at your own label and you are walking the loop your own number sits in. Your number is the one that would send you back to the box you began at, so it is the last link in the loop. You find it on your final step — and the number of steps is simply the length of your chain.
So everybody finds their number if and only if no chain is longer than the number of boxes they may open. Press Walk the longest chain and follow the only loop that can cost them the room.
That is the whole trick, and it is worth being precise about what it did. Each prisoner's own chance is still exactly one in two — nobody guesses better than before. What changed is that the failures are no longer independent. Before, each flipped their own coin, and a hundred coins all landing heads is hopeless. Now there is one question — does any chain run longer than fifty? — and the whole room turns on the answer. When they lose it is not that all hundred fail: the prisoners on the over-long chain fail and the rest find their numbers. But the room needs every one of them.
A hundred small independent chances multiply down to nothing. One big chance does not. The histogram below is that one question, asked over and over: rooms left of the marker walked free, rooms right of it did not.
Look at the shape of that tail. It falls away slowly instead of tapering off like a bell, because for any length past half the room, the chance that a chain of exactly that length exists is exactly 1/L. A 90-chain is two-thirds as likely as a 60-chain. Past half the room only one such chain can fit, which is what makes 1/L exact; below half several can, and the law there is a different one.
So the losses spread right across the tail instead of piling up just over the line. Only about one loss in seven has its longest chain in the fifties, and about one in four is inside sixty. Most of the time, they do not lose narrowly.
Now drag Boxes each may open. Every equal step buys less than the one before it: at a hundred prisoners, half to sixty per cent lifts them 18 points, eighty to ninety only 12, and the last ten points are worth 10. Each extra box strikes one more length off the danger list, and the lengths still on it are the rare long ones.
The slider stops at half, and that is not squeamishness. Below half the sum that gives the exact answer stops being valid, because two long chains can then coexist and the bad cases start double-counting. The number on screen would simply be wrong, so the control does not go there.
Thirty-one per cent is the answer for a hundred. The famous figure, 1 − ln 2 = 30.685%, is the limit as the room grows, and it sits half a point below the truth at a hundred. Drag the room size and watch the exact value fall towards it without ever reaching it.
And under the usual rules — the labels fixed, no communication once anyone is inside, every prisoner deciding only from what they have opened — no agreement they could have made does better than this one. Starting at your own box is the only opening move that puts you on the chain your own number sits on. Start anywhere else and that guarantee is gone, which the committed check confirms by trying the alternative and watching it fail every single time.
The rule, exactly. The boxes are a uniformly random permutation of 1…n.
Following the chain from your own box finds your number on step L, where L is the
length of your cycle, so everyone succeeds precisely when the permutation has no cycle longer than
k. Since two cycles longer than n/2 cannot both fit, those bad events are disjoint,
and the permutations of n containing a cycle of length exactly L number
C(n,L) · (L−1)! ·
(n−L)! = n!/L
so each has probability 1/L, and for k ≥ n/2
P(everyone free) = 1 − ∑L=k+1n
1/L = 1 − (Hn − Hk)
which is 31.1828% at n = 100, k = 50, and tends to 1 − ln 2 = 30.6853%.
The problem is due to Gál and Miltersen (2003) and was popularised by Peter Winkler.
Checked before this page was written (improve/verify/133-hundred-prisoners.js):
Also in Games & choices: Nash equilibria →
Thought Toys · exhibit 133 · built 12 September 2026