Get AI summaries of any video or article — Sign up free
The Riddle That Seems Impossible Even If You Know The Answer thumbnail

The Riddle That Seems Impossible Even If You Know The Answer

Veritasium·
6 min read

Based on Veritasium's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Random guessing yields a success probability of (1/2)^100, effectively zero, because each prisoner’s 50-box search is independent in that naive approach.

Briefing

A counterintuitive prison riddle turns out to have a surprisingly high escape chance—about 31%—once prisoners stop treating their searches as independent coin flips and instead follow a shared “follow the permutation” strategy. In the classic setup, 100 prisoners each may open only 50 boxes to find the slip with their own number; if even one fails, all are executed. Random guessing gives an astronomically small success probability of (1/2)^100, essentially zero.

The winning plan is simple: when a prisoner enters, they open the box labeled with their own number, read the number inside, then go to the box with that number. They repeat this chain—always jumping to the box indicated by the slip they just found—until they either locate their own slip or they run out of the 50-box limit. This works because the arrangement of slips and box labels forms a directed graph where every box points to exactly one other box. That structure decomposes into disjoint cycles (“loops”). Starting from the box with a prisoner’s number guarantees that the prisoner will stay on the cycle containing their own slip.

Whether a prisoner succeeds depends entirely on the cycle length. If the cycle containing their number has length 50 or less, the prisoner will reach their slip within the allowed 50 steps. If the cycle length is 51 or more, the prisoner will not find their slip before exhausting the 50-box search. Crucially, all prisoners on the same long cycle either succeed together or fail together, because they are trapped in the same loop structure.

So the group success probability becomes a question about random cycle lengths: what is the chance that a random arrangement of 100 slips into 100 boxes contains no cycle longer than 50? Computing this requires counting cycle structures within permutations. The probability that a random permutation has a cycle of length exactly k is 1/k, and the probability of having any cycle longer than 50 is the sum 1/51 + 1/52 + … + 1/100. That sum is about 0.69, meaning a 69% failure rate and roughly a 31% chance that all 100 prisoners escape.

The riddle also resists “it only works for 100” skepticism. For larger numbers of prisoners, the success probability stays near 30.7% and approaches a limit. Using the same harmonic-series logic, the failure probability converges to ln(2), so the success probability approaches 1 − ln(2) ≈ 30.7%. The strategy’s power comes from coupling everyone’s outcomes through the shared cycle decomposition: instead of each prisoner having an independent 50% shot, the group either clears the 50-step constraint for every cycle or it doesn’t.

Even potential adversarial interference has a twist. A guard who swaps two boxes can split a single too-long cycle into shorter ones, improving odds. A guard who anticipates the strategy can force long cycles, but the prisoners can counter by renumbering boxes (equivalently randomizing the permutation), restoring the same ~31% baseline. The bottom line is that what initially feels impossible—everyone finding their number with only half the boxes—actually holds steady at better than a 30% chance, even as the prisoner count grows without bound.

Cornell Notes

The classic 100-prisoner box riddle has an essentially zero success chance if each prisoner searches randomly. The breakthrough is a shared strategy: start at the box with your number, then repeatedly open the box whose label matches the number you just found, until you either find your own slip or hit the 50-box limit. The arrangement of slips into boxes forms disjoint cycles (loops) in a permutation. A prisoner succeeds exactly when their cycle length is 50 or less; otherwise they fail after 50 steps. Group success happens precisely when there is no cycle longer than 50, which occurs with probability about 31% (failure about 69%). As the number of prisoners grows, the success probability approaches 1 − ln(2) ≈ 30.7%.

Why does the “follow the numbers” strategy outperform random searching so dramatically?

Because the slips and box labels define a permutation: each box points to exactly one other box (the box labeled with the number on the slip inside). Any permutation decomposes into disjoint cycles. Starting from the box labeled with your number forces you to stay on the cycle containing your slip. If that cycle has length ≤ 50, your own slip appears within your allowed 50 openings; if the cycle length is ≥ 51, you will not reach your slip before you run out of allowed searches.

What determines whether a prisoner finds their own number—random chance at each step or something more structural?

Cycle length. When a prisoner begins at their own-number box, they start at the farthest point on their cycle from their slip. That means the prisoner’s search succeeds if and only if the cycle length is 50 or shorter. For cycle length 51, for example, every prisoner on that cycle fails together: they reach the box just before their slip but must stop at 50 openings.

How is the group success probability computed for 100 prisoners?

Group success requires that the random permutation has no cycle longer than 50. The probability that a random permutation contains a cycle of length exactly k is 1/k. Therefore the probability of failure (at least one cycle longer than 50) is 1/51 + 1/52 + … + 1/100 ≈ 0.69. That leaves success probability ≈ 1 − 0.69 = 0.31 (about 31%).

Why are the prisoners’ outcomes not independent even though each can open only 50 boxes?

Each prisoner’s individual chance of success remains 50% because each prisoner still has only half the boxes to search. But the events are correlated: prisoners on the same cycle share the same fate. In repeated experiments, random guessing yields around 50 successes most of the time, but the loop strategy produces all-or-nothing behavior tied to whether any cycle exceeds length 50.

What happens as the number of prisoners grows very large?

The success probability approaches a constant near 30.7%. The failure probability becomes a harmonic-series tail that converges to ln(2). With n prisoners each allowed to open n/2 boxes (mirroring the 50-of-100 structure), the limiting success probability is 1 − ln(2) ≈ 0.307. The strategy’s advantage persists; the main practical constraint becomes time to open many boxes.

How can a guard affect the outcome, and why can prisoners still recover?

A sympathetic guard can guarantee success by swapping two boxes, splitting the at-most-one cycle longer than 50 into two shorter cycles. A malicious guard can instead arrange slips to force a long cycle. But prisoners can counter by arbitrarily renumbering the boxes (e.g., adding a constant to every box label), which effectively randomizes the cycle structure again, returning the situation to the original ~31% success probability.

Review Questions

  1. In the loop strategy, what exact condition on the cycle length guarantees a prisoner finds their slip within 50 openings?
  2. Why does the probability of all prisoners succeeding reduce to “no cycle longer than 50,” and how does the sum 1/51 + … + 1/100 relate to failure?
  3. For very large numbers of prisoners, what constant does the success probability approach, and how is it connected to ln(2)?

Key Points

  1. 1

    Random guessing yields a success probability of (1/2)^100, effectively zero, because each prisoner’s 50-box search is independent in that naive approach.

  2. 2

    The optimal coordinated strategy is to follow the chain: open your-number box, then jump to the box labeled with the number you find, repeating until you either find your slip or hit 50 steps.

  3. 3

    The arrangement of slips into boxes forms disjoint cycles (loops) in a permutation, and starting from your-number box traps you on the cycle containing your slip.

  4. 4

    A prisoner succeeds if and only if the cycle containing their slip has length at most 50; otherwise they fail after exhausting 50 openings.

  5. 5

    All prisoners on the same long cycle succeed together or fail together, creating strong dependence between outcomes.

  6. 6

    For 100 prisoners, the group succeeds with probability about 31% because failure equals the chance of at least one cycle longer than 50: 1/51 + 1/52 + … + 1/100 ≈ 0.69.

  7. 7

    As the prisoner count grows, the success probability approaches 1 − ln(2) ≈ 30.7%, staying above 30% even for arbitrarily large groups.

Highlights

The loop strategy turns an impossible-feeling (1/2)^100 problem into a ~31% group success chance by exploiting cycle structure in permutations.
Whether anyone finds their number depends only on the length of the cycle containing their slip, not on step-by-step randomness.
The prisoners’ outcomes become correlated: they either all win together when no cycle exceeds 50, or they fail hard when a long cycle exists.
The limiting success probability for large numbers is 1 − ln(2) ≈ 30.7%, so the odds don’t collapse as the group grows.
A guard can improve or worsen outcomes by manipulating cycle lengths, but prisoners can restore the baseline by renumbering boxes, effectively re-randomizing the permutation.

Topics

  • Permutation Cycles
  • Probability
  • 100 Prisoners Riddle
  • Harmonic Series
  • Limit Behavior

Mentioned