What the Empty Square Knows About a Puzzle

Mechanical Puzzle Collecting 🎮 Play: The Collector’s Cabinet

I went looking for another wire puzzle and came home with a small wooden 15-puzzle. The tiles sit in a square frame with one space between them. The shopkeeper slid a few around, handed it over, and watched me spend a minute returning them to order. I bought it partly because I wanted to know what would happen after more than a minute of rearranging.

The empty space turns out to be a useful thing to follow. It also provides a way to check whether a particular arrangement can be solved at all.

Counting what’s out of order

The standard goal has fifteen numbered tiles and an empty square, here marked with a dash:

 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15  -

A legal move slides one adjacent tile into the empty square. Tiles do not lift out or pass through each other. If you start with the goal above, make legal moves to scramble it, and then reverse those moves, you can always get back. That is a dependable way to prepare a challenge, even if you don’t record the moves.

A second-hand puzzle with loose tiles presents a different question. Someone might have put them back in an arrangement that cannot reach the goal by sliding. To check, count the inversions.

Read the numbered tiles across each row, from top to bottom, ignoring the empty space. An inversion is a pair where a larger number comes before a smaller one. For example, in this shortened sequence:

1  3  4  2

There are two inversions: 3 comes before 2, and 4 comes before 2. The 3 and 4 are in their usual relative order, so they don’t add one.

For a full board, count every such pair. Then add the row number of the empty space, counting from the bottom of the frame. For the standard goal shown above, the inversion count is zero and the empty space is in row 1 from the bottom. The sum is 1.

On a 4-by-4 puzzle with that goal, an arrangement is solvable exactly when this sum is odd. Here is the test in practice:

 1  2  3  4
 5  6  7  8
 9 10 11 12
13 15 14  -

Only one pair is inverted: 15 comes before 14. The empty square is still in row 1 from the bottom, so the sum is 1 + 1 = 2. It is even. This arrangement cannot reach the standard goal through legal slides. The Smithsonian’s description of a related word puzzle notes that this particular 14–15 challenge was known to be impossible before Sam Loyd promoted it.

Why the check survives a slide

The test works because a legal move preserves whether that sum is odd or even. This property is called parity.

Slide a tile horizontally and the numbered tiles stay in the same reading order: a tile moves past the empty space, which we ignore when counting inversions. The empty space also stays in the same row. Neither part of the sum changes.

Slide a tile vertically and it moves past three numbered tiles in reading order. For each of those three, the move either creates or removes an inversion. Three such changes flip the parity of the inversion count. At the same time, the empty space moves to an adjacent row, flipping the parity of its row number. Both parts flip, so their sum keeps the same parity.

The goal has an odd sum. A legal slide cannot turn an even sum into an odd one, so an even arrangement cannot reach it. The odd-sum test also tells us the converse for this standard board: those arrangements can reach the goal.

Counting inversions by hand takes a little care. I worked left to right through my tiles, checking each number against the numbers after it and putting a small tally beside each count. It helped to copy the sequence onto paper first. Counting directly from the wooden board, my eye kept returning to the same row and trying to invoice tile 12 twice.

Before putting the puzzle away, I slid it out of order and photographed the arrangement. A photograph captures a starting position; a short move log captures the route as well. I labelled moves by the number on the tile entering the gap, so 15, 14 means those two tiles moved in that order. To undo the sequence, move the same tiles in reverse order.

My first entry in the collection catalogue now has a photograph, the goal, and a note that the tiles should move freely. Frank E. Moss’s 1901 sliding-puzzle patent specifies a little clearance around the blocks for exactly that reason. Mine has one corner that catches slightly when I press near the edge. It slides more readily from the centre, so I left the frame alone and finished writing down the moves.