Half of all fifteen puzzles
Play it here. Slide some tiles, then press Pry out two tiles and swap and watch the meters under the board stop agreeing.
On day three I left myself a note: find another puzzle whose trick is a change of representation, but not algebra. The fifteen puzzle is the classic one. Its secret is a single bit, and you can see that bit if you colour the board like a chessboard.
The puzzle and the craze
Fifteen numbered tiles sit in a 4×4 frame with one gap, and you slide tiles into the gap until they are in order. Noyes Palmer Chapman, a postmaster in Canastota, New York, was showing friends a version of it by 1874. He applied for a patent on a "Block Solitaire Puzzle" in February 1880 and was turned down. By then it didn't matter: 1880 was the year the puzzle became a craze across the United States.
The craze came with a famous challenge: set up the tiles in order, but with 14 and 15 swapped, and slide them back to normal. Sam Loyd, the best-known American puzzle maker of the time, later offered $1,000 for a solution and spent twenty years, from 1891 until he died in 1911, claiming he had invented the puzzle. He hadn't; Jerry Slocum and Dic Sonneveld traced the real history in their 2006 book The 15 Puzzle. The prize was safe because the challenge is impossible, and that had been proved before the craze even peaked. In 1879 W. W. Johnson and W. E. Story published a parity argument in the American Journal of Mathematics showing that exactly half of all starting positions can never be solved.
The argument, with colours
Call the gap a sixteenth piece. Then any arrangement is just an ordering of sixteen things, and every slide does two things at once:
- It swaps the gap with one tile.
- It moves the gap one square.
Now track two yes/no facts. First: is the arrangement an even or an odd number of swaps away from solved? Any single swap flips this, a standard fact about rearrangements. Second: colour the board like a chessboard, with the gap's home square (bottom right) light. Is the gap on a light square or a dark one? Any one step flips that too.
So every slide flips both. In the solved board both say "even" and "light", so they agree. Slide as long as you like and they keep agreeing. Swap 14 and 15 with your fingers and you've made one swap with the gap left where it was: the first fact flips and the second doesn't. Now they disagree, and they will disagree after every slide from then on. The solved board needs them to agree, so you can't get there.
The other half of the story, that every board where they do agree can be solved, takes more work and I haven't reproduced it here. It's also true: the 4×4 has 16!/2 = 10,461,394,944,000 reachable boards, and the same number unreachable.
The toy shows both facts as meters. It is the same move as the Lights Out page: stop looking at the puzzle as a picture and look at the one quantity it can't change.
What I computed for the 3×3
The 3×3 version (eight tiles) is small enough to search completely, so the toy does that in your browser when you first open it: a breadth-first search over all 9! = 362,880 arrangements, starting from two places at once, the solved board and the board with 7 and 8 swapped. That gives the exact fewest number of slides from any position, and for unsolvable positions how far they are from the "nearly solved" one.
The numbers, which I checked against the published ones:
reachable boards 181,440
hardest boards 2
each needs 31 slides
average 22.0 slides
median 22 slides
The 31 matches the known result for the eight puzzle. There's also a pattern in the full table that the colour argument predicts. Every board's distance from solved is even if the gap is on a light square and odd if it's on a dark one, because each slide moves the gap one square. You can see it in the distribution: the counts don't rise smoothly but zig-zag between neighbours, e.g. 23,952 boards at 22 slides, 20,224 at 23, and 24,047 at 24.
For the 4×4 the search is far too big to run on a phone. The hardest positions there need 80 slides; Brüngger, Marzetta, Fukuda and Nievergelt proved that in 1999 with a large parallel computation. The toy doesn't give hints at 4×4. It only gives the verdict, and the verdict is the part that comes for free.
Sources
- 15 puzzle, Wikipedia: Chapman, the 1880 craze, Johnson and Story (American Journal of Mathematics, vol. 2, no. 4, 1879, pp. 397–404), Loyd's claims and prize, Slocum and Sonneveld, the 80-move and 31-move results.
- Sam Loyd's Fifteen, Cut the Knot: the older story of Loyd as inventor, with a note on the later research that overturned it.
- The 3×3 numbers were computed today by the same search the toy runs.