Lesson
The theory — Invariants
An invariant is a quantity that no allowed move changes. If it has one value at the start and a different value at the goal, the goal cannot be reached, whatever moves are tried, and nothing has to be searched to know it.
What each symbol means
I- the invariant: here the parity of the inversion count, the difference between black and white squares, or the number of land masses with an odd number of bridges
d(v)- the degree of a land mass v: how many bridges end there
Where the formula comes from
- Why a slide keeps the parity. Read the eight tiles row by row, ignoring the gap. A sideways slide does not change that reading order at all. An up-or-down slide moves one tile three places along it, past the two tiles between its old square and its new one. Each of those two pairs gains or loses an inversion, so the count changes by −2, 0 or +2, never by an odd number. Solved has 0, so a position with an odd count cannot be reached. That every position with an even count can be reached is the harder half: for the 8-puzzle the page’s search shows it directly.
- Why a domino keeps the difference. On a chessboard every square’s neighbours are the other colour, so a domino, which covers two neighbouring squares, covers one black and one white. Laying dominoes therefore never changes black minus white among the uncovered squares. A finished tiling leaves nothing uncovered, a difference of 0, so it needs a difference of 0 at the start: as many squares of one colour as of the other.
- Why at most two odd land masses. Follow the walk. Each time it passes through a land mass it arrives by one bridge and leaves by another, so the bridges at a land mass are used in pairs, except at the start, where one is used leaving, and at the end, where one is used arriving. If the walk ends where it started, every land mass has an even number of bridges; otherwise exactly the start and the end have an odd number. The converse also holds when the bridges join everything up, and the page finds the walk by building it in loops and splicing them together.
Problem solved in full
-
Could anyone win Sam Loyd’s $1,000? 4 steps
On the 4 × 4 board, swap only 14 and 15 and leave the gap in its corner. Sam Loyd offered $1,000 to anyone who could slide that back to solved. Could it be done?
-
On this page’s 3 × 3 board, the invariant was the parity of the inversion count:
-
On a board four wide, an up-or-down slide carries a tile past three others, so the count changes by an odd number, and the gap changes row:
-
Every slide flips both parities or neither, so their sum, taken mod 2, never changes:
-
Compare the two positions, with the gap in row 4 in both:
Answer
Nobody could win it: the swap lies on the wrong side of the invariant. Exactly half of the 16! arrangements, 10,461,394,944,000, can be reached from solved. Press 7 and 8 swapped for the 3 × 3 version of the same trap.
-
Learning path
Methods of proof
References (3)
- The parity argument for the 15-puzzle, the history (made in upstate New York in the 1870s, a craze in early 1880, analysed in the American Journal of Mathematics that year) and Sam Loyd's later $1,000 prize for a swap that cannot be done: K. Conrad, "The 15-Puzzle (and Rubik's Cube)", expository notes, University of Connecticut.
- Euler's paper on the seven bridges of Königsberg, which reduced the walk to the number of bridges at each land mass: L. Euler, "Solutio problematis ad geometriam situs pertinentis", Commentarii academiae scientiarum Petropolitanae 8, 128–140 (written 1735, published 1741); Eneström number E53, The Euler Archive.
- The number of domino tilings of square boards, with 12,988,816 for the 8 × 8 chessboard: OEIS Foundation, "A004003: Number of domino tilings (or dimer coverings) of a 2n X 2n square", The On-Line Encyclopedia of Integer Sequences.