DEV Community

Small Web Tools Notes
Small Web Tools Notes

Posted on

Why the Ladder Game (Amidakuji) Never Gives Two People the Same Prize

Amidakuji, also called the ladder lottery or Ghost Leg, is a simple way to draw lots. Each player picks a vertical line at the top and follows it down; whenever a horizontal rung appears, they must cross it. However messy the ladder looks, every player ends at a different bottom position. Here is why that is guaranteed, and the neat bit of mathematics behind it.

The rules

  • There are N vertical lines and N results at the bottom.
  • Horizontal rungs connect neighbouring lines, at different heights.
  • A player walks down their line and crosses every rung they meet.

The ladder game on blockblast.co hides the results until you trace each name, so you can watch the paths unfold.

Each rung is a swap

Think of the players as tokens sitting on the lines. When a rung joins line i and line i+1, the two tokens on those lines swap places. Nothing else changes. So a ladder is just a sequence of swaps of neighbouring positions, applied from top to bottom.

In mathematics, a swap of two neighbouring positions is called an adjacent transposition. Composing transpositions always gives a permutation: a rearrangement where every item lands in exactly one place.

Why no collisions

A swap is a one-to-one operation: it takes two tokens and exchanges them, never merging them. A sequence of one-to-one operations is still one-to-one. Therefore, at the bottom, each line holds exactly one token. No two players can end on the same result, and no result is left empty.

There is one rule that keeps this true: rungs at the same height must not share a line. If a line had rungs on both sides at the same height, a player would not know which to take. Proper ladders avoid that, and digital versions generate them correctly.

Every outcome is possible

The reverse is also true: any assignment of players to results can be produced by some ladder. This follows from the fact that adjacent transpositions generate all permutations, which is essentially what bubble sort demonstrates: you can sort any list using only neighbour swaps. Each swap bubble sort makes corresponds to a rung.

Is it fair?

Fairness depends on how the ladder is built, not on the structure. If rungs are placed randomly and in enough quantity, outcomes are well mixed. With very few rungs, players tend to end up close to where they started, which is predictable. Adding players or results after seeing the ladder would also break fairness, which is why results are hidden until the ladder is fixed.

A quick experiment

Draw three lines and one rung between lines 1 and 2. Player 1 ends at result 2, player 2 at result 1, and player 3 stays put. Add a rung between lines 2 and 3 below the first. Now trace again: the mapping becomes a cycle. Small examples make the permutation idea concrete.

Related tools

If you need a quick random choice from a list rather than a matching, Spin the Wheel picks one entry at random. Both are listed with other browser games on the games page.

Summary

  • Each rung swaps two neighbouring players.
  • Swaps compose into a permutation, so outcomes never collide.
  • Any matching can be produced by some ladder.
  • Fairness comes from random, plentiful rungs and hidden results.

Top comments (0)