Ledger

Work through a book of entries recording who paid what to whom, following the trail from one to the next instead of guessing at the answer. The gap between those two approaches is wider than anyone believes until they see it.

How to play

Tapping two drawers swaps the dockets inside them, and that is the only move you have.

  1. Find the long loop It is outlined in red, and its length is listed underneath. Everything else can be ignored.
  2. Swap inside it, not across it Swapping the contents of two drawers on the same loop splits it in two. Swapping across two different loops joins them into one, which is the wrong direction.
  3. Mind where you cut A loop of twelve with a limit of four needs two swaps, and every piece must come out at four or less — so the cuts have to be spaced, not bunched.
Full instructions

In depth

Breaking loops so every clerk finds their docket

What the loop trail is, why swapping inside a loop splits it, how the swap budget is calculated, and the thinking method that turns a hard-looking puzzle into simple arithmetic.

Screenshot: How to play Ledger
How to play Ledger as it appears when the page opens.

The problem behind the puzzle

A row of drawers contains numbered dockets, one per drawer, all in the wrong order. A clerk who needs docket seven opens drawer seven, reads the number inside, opens that drawer next, and follows the chain. Because every number appears exactly once, that chain always comes back to where it started. The chain forms a loop.

The loop might be short. A clerk opens three drawers and finds their docket. Or it might be long. A clerk opens twelve drawers before the trail comes back around. The trouble is that each clerk may only open a limited number of drawers. If their loop is longer than that limit, they never find their docket.

Your job is to swap dockets between drawers until no loop is longer than the limit. You have a fixed number of swaps to do it.

Reading the board

Each drawer is shown as a numbered box with a coloured slip inside it. The slip shows which docket is in that drawer. Drawers on the same loop share a colour, so you can see the loops at a glance.

Below the drawers is a list of loops with their lengths. Any loop longer than the limit is marked in red and labelled too long. Short loops that already fit within the limit have no marker.

The stats bar shows three numbers. Longest loop tells you the current longest and what the limit is. Swaps left tells you how many more swaps you can make. Fewest swaps tells you the smallest number of swaps that could solve this arrangement, which is the par for the puzzle.

Controls and board sizes

Tap or click a drawer to select it. It highlights. Tap a second drawer to swap their contents. If you tap the same drawer again, the selection clears and nothing happens.

A dropdown labelled Office offers three sizes. Small has nine drawers and a limit of three. Medium has twelve drawers with a limit of three. Large has fifteen drawers and a limit of four. The New game button generates a fresh arrangement.

The swap budget is the par plus a small amount of slack. On small and medium boards you get one extra swap beyond par. On large boards you get two. If you run out of swaps before every loop is short enough, the game ends.

Same loop splits, different loops join

This is the single most important rule. When you swap the contents of two drawers that are on the same loop, the loop splits into two shorter loops. When you swap the contents of two drawers on different loops, the two loops merge into one longer loop.

Splitting is what you want. Merging is the opposite. Before every swap, check the colours. If both drawers share the same colour, you are about to split. If they have different colours, you are about to merge, and the result will be worse than where you started.

A merge is not always fatal. Sometimes merging two short loops and then splitting the result in a better place costs fewer total swaps. But that is an advanced move. For most puzzles, the rule is simple: never swap across colours.

Where to cut a long loop

A loop of length nine with a limit of three needs two swaps. Each swap splits the loop into two pieces. But the pieces must all be three or shorter, so the cuts have to be spaced evenly.

Think of the loop as a circle of drawers. If you cut it near the top and near the bottom, you get three roughly equal pieces. If you cut it twice next to each other, you get one tiny piece and one piece that is still too long. Spacing matters.

The formula for the minimum number of swaps on a single loop is its length divided by the limit, rounded up, minus one. A loop of twelve with a limit of four needs two swaps. A loop of five with a limit of three needs one. Add those numbers across all long loops and you get the par.

A worked example on a medium board

Twelve drawers, limit of three. The board shows one red loop of length seven, one blue loop of length three, and one green loop of length two. The blue and green loops are already safe. Only the red loop needs work.

Seven divided by three, rounded up, is three. Minus one gives two swaps needed. You need to cut the red loop into three pieces, each of length three or less. The possible splits are 3-4 into 3 and 4, then 4 into 2 and 2. Or 3-2-2. Either way, two swaps and every piece fits.

Pick two drawers on the red loop that are three steps apart in the chain. Swap them. The loop splits into a piece of three and a piece of four. Now pick two drawers on the remaining four-long piece that are two steps apart. Swap. Three pieces, all within the limit, and the board turns green.

Short loops need nothing

Any loop at or under the limit is already safe. Leave it alone. A common mistake is to touch a short loop by accident, merging it with another one and creating a problem that did not exist before.

Before you start swapping, count the long loops and figure out how many swaps each one needs. If the total matches the par, you know exactly how many moves you have to work with. Every swap should be aimed at a specific long loop.

The mathematics that makes it surprising

The puzzle is built on a famous result in probability. Give a hundred clerks a hundred drawers and let each one open fifty. If they open drawers at random, the chance that all hundred succeed is vanishingly small. But if every clerk follows the trail from their own number, the chance jumps to about thirty-one per cent.

The reason is that the trail strategy ties everyone's fate to the loops. All clerks on the same loop succeed or fail together, and the whole group survives exactly when no loop is longer than half the drawers. The chance of a random shuffle having no loop longer than half is one minus the natural logarithm of two, roughly 0.307.

The puzzle version tightens the limit to a third of the drawers instead of half. With half, a single swap always fixes everything, and there is nothing to work out. A tighter limit makes the cut placement matter.

Difficulty levels and what changes

The three sizes are not just bigger grids. They play differently because the ratio of loop length to limit changes.

On a small board with nine drawers and a limit of three, the longest possible loop is nine, which needs two swaps. The puzzles are designed so that par is between two and four. You can usually see the whole arrangement at once and plan all your cuts before tapping anything.

Medium boards have twelve drawers and the same limit of three. Loops can reach twelve, needing three swaps. The extra drawers make it harder to see which drawers belong to which loop without checking the colours carefully.

Large boards jump to fifteen drawers and a limit of four. The wider limit means each loop can be longer before it needs a cut, but the sheer number of drawers makes the board harder to scan. Read the loop list below the drawers rather than tracing paths visually.

Common mistakes to watch for

  • Swapping across two different loops. Check the colours first. Different colours mean a merge, not a split.
  • Cutting a loop in the wrong place. Two cuts bunched together leave one piece still too long. Space them evenly around the loop.
  • Spending swaps on short loops. Anything at or below the limit needs no work. Focus only on the red ones.
  • Not counting before you cut. Figure out how many swaps each long loop needs and add them up. If the sum exceeds your budget, you need to find a more efficient path.
  • Forgetting that merging and re-splitting is sometimes cheaper. Two short loops can be merged and re-split into different sizes if that helps break a longer loop with fewer total moves. It is rare, but worth knowing.

No data leaves your browser

The shuffle, the loop detection, and the swap counting all happen on your own device. No arrangement is sent anywhere. There is no account and no saved history. Close the tab and the puzzle is gone.

Help

How to play Ledger

Tapping two drawers swaps the dockets inside them, and that is the only move you have. The trails always close into loops, drawn in matching colours so you can see them, and the limit written above the cabinet is the longest loop anyone is allowed to walk. Get every loop down to that length or shorter and the ledger balances.

Find the long loop

It is outlined in red, and its length is listed underneath. Everything else can be ignored.

Swap inside it, not across it

Swapping the contents of two drawers on the same loop splits it in two. Swapping across two different loops joins them into one, which is the wrong direction.

Mind where you cut

A loop of twelve with a limit of four needs two swaps, and every piece must come out at four or less — so the cuts have to be spaced, not bunched.

Count the swaps first

A loop needs its length divided by the limit, rounded up, less one. Nothing you do can beat that.

A hundred prisoners and a third of a chance

The original problem gives a hundred prisoners a hundred boxes containing their numbers in some order. Each may open fifty boxes, and all of them must find their own number or every one is lost. They may agree a plan beforehand but cannot communicate once it starts. Opening boxes at random gives each prisoner a one in two chance, so all hundred succeeding has a probability of one in a nonillion — effectively zero. The strategy of following the trail from your own number changes that to about thirty-one per cent, because it makes the outcomes depend on one another: everybody on a loop succeeds or fails together, and the room survives exactly when the longest loop is fifty or shorter. The chance of a random shuffle having no loop longer than half is one minus the natural logarithm of two, which is 0.307 and barely moves as the numbers grow. Anna Gal and Peter Bro Miltersen found the idea in 2003, in a paper about something else entirely.

Good to know

Same loop splits, different loops join

That single fact is the whole technique. Check the colours before you swap.

Short loops are already safe

Any loop at or under the limit needs nothing done to it. Leave it alone.

Everyone on a loop shares its fate

A clerk succeeds exactly when their own loop is short enough — so fixing a loop saves everybody on it at once.

The limit is a third of the drawers

Tighter than the classic half, because with half a single break always suffices and there is nothing to work out.

Common questions

Why does swapping within a loop split it?
Because the trail is redirected back on itself early, closing one loop and leaving the rest as another.
Can I make things worse?
Easily. Swapping between two different loops merges them into one longer one.
Does the clerk get to choose which drawers to open?
They follow the trail, which is the whole point. Choosing freely would be far worse.
Is the fewest-swaps figure exact?
Yes. Each loop needs its length divided by the limit, rounded up, less one, and those add up.
Is thirty-one per cent really the answer for a hundred?
About that — one minus the natural logarithm of two, and it hardly changes however many prisoners there are.