LibraryQuant brainteasers

Hundred Prisoners and Boxes Puzzle Odds

Quant brainteaser · hard · members

The question

A hundred numbered boxes sit in a room, each containing a slip of paper with one of the numbers 1 through 100, each number used exactly once (a bijection between boxes and slips, unknown to the prisoners). A hundred prisoners, also numbered 1 through 100, are let into the room one at a time. Each prisoner may open at most fifty boxes, must find the slip bearing their own number, and must leave the room exactly as they found it, without communicating anything to the others.

Every prisoner must find their own number for the whole group to be freed. If even one prisoner fails, all are executed. The prisoners may agree on a strategy beforehand, but not afterward.

If every prisoner opens fifty boxes chosen independently at random, the chance any one of them succeeds is 1/21/2, and the chance all hundred succeed independently is (1/2)100(1/2)^{100}, indistinguishable from zero. Find a strategy that does dramatically better, and say roughly how much better.

Hint

Each slip carries a number that is also the label of a box. Ask where a prisoner could go next after opening a box, and whether every prisoner could follow the same rule.

The idea behind it

Do not search a random object with a random policy. A permutation carries structure (its cycles), and a strategy that walks the structure instead of guessing turns a vanishing success probability into a constant one, because it makes every prisoner's fifty guesses depend on the same fixed path rather than fifty independent coin flips.

The worked solution is for members

You have the question, a hint and the idea. It sets out a strategy for the whole group, proves why it works, and computes the chance that everyone goes free.

Further reading

Topics

Also in the library