An unsolvable sliding puzzle is one whose tiles have the wrong parity. Count the inversions — pairs of tiles in the wrong order. On a 3x3 (odd width) the puzzle is solvable only if that count is even; on a 4x4 add the blank’s row counted from the bottom, and the total must be odd.
Click a cell and type its number. Use arrows to focus, Backspace to clear, Enter to solve. Separate two-digit tiles with a space.
Solvable
Inversions: 0 (counting out-of-order nonblank pairs); an even count is required for an odd-width board.
Enter your board in the checker below to see the count worked out for you, or read on to do it by hand.
How to count inversions
An inversion is a pair of tiles in the wrong order. To count them, read the tiles left to right, top to bottom, skipping the blank. Then, for each tile, count how many smaller tiles come after it, and add up those counts.
Here is a 3x3 board that looks almost finished:
| Tile | Smaller tiles after it | Count |
|---|---|---|
| 1 | none | 0 |
| 2 | none | 0 |
| 3 | none | 0 |
| 4 | none | 0 |
| 6 | 5 | 1 |
| 5 | none | 0 |
| 7 | none | 0 |
| 8 | none | 0 |
| Total | 1 |
One inversion is an odd number, so this board is an unsolvable sliding puzzle. It doesn’t matter how close it looks to finished: a single pair of tiles in the wrong order is enough.
On a bigger board the counting takes longer but works the same way. A quick shortcut: tiles that are already in their home squares at the start of the reading order (1, 2, 3 and so on) never add anything, so you can start counting from the first tile that’s out of place.
The rule for 3x3 and 5x5 boards
On a board with an odd width, the rule has one step: an even inversion count means solvable, an odd count means impossible.
Where the blank sits makes no difference. Sliding a tile left or right doesn’t change the reading order at all. Sliding a tile up or down jumps it past an even number of other tiles (two on a 3x3, four on a 5x5), which changes the count by an even number, so even stays even and odd stays odd.
For a 5x5, read all 24 tiles in order and apply the same test.
The rule for 4x4 boards
On a 4x4 (or any even width), sliding a tile up or down jumps it past three other tiles, an odd number, so the inversion count alone isn’t enough. The blank’s row has to be counted too:
- Count the inversions as before.
- Add the row the blank is in, counted from the bottom (the bottom row is 1, the top row is 4).
- If the total is odd, the board can be solved. If it is even, it can’t.
The classic example is the 14-15 puzzle: everything in order except 14 and 15, with the blank in the bottom-right corner.
For comparison, the finished board has 0 inversions and the blank in row 1, a total of 1, which is odd. That’s the “good” parity every solvable 4x4 shares. If you’d like to solve a board that passes the test, the 4x4 sliding puzzle solver finds the shortest solution.
Why half of all arrangements are impossible
The key fact is that every legal slide keeps the parity of the total the same. You can see it on the 14-15 puzzle. Slide 12 down into the blank:
The numbers change, but even stays even. The solved board is on the odd side, so a board on the even side can never reach it, no matter how many moves you make. There is no trick or clever sequence that gets around it.
Exactly half of all arrangements land on each side. On a 3x3 there are 9! = 362,880 ways to place the tiles, and 181,440 of them can be solved. On a 4x4 about 10.46 trillion arrangements can be solved, and just as many can’t.
This is what made the 14-15 puzzle famous. Sam Loyd claimed to offer $1,000 to anyone who could solve it, and because the position is impossible, nobody could ever collect the prize. The mathematics had already been settled: in 1879 Johnson and Story proved in the American Journal of Mathematics that half of all starting positions of the puzzle can’t be solved.
What to do with an unsolvable sliding puzzle
Check the board you entered. This is by far the most common cause. One mistyped number, a tile read upside down (6 and 9 are easy to confuse), or a tile missed in a screenshot is enough to flip the parity. Compare every square with your real puzzle before anything else.
On a physical puzzle, two tiles may have been swapped. Many sliding puzzles can be taken apart, and if two tiles were put back in each other’s places, the puzzle can’t be finished. Nothing you do with the tiles in the frame will fix it.
Swap any two tiles (not the blank). One swap flips the parity, so any impossible board becomes solvable. The checker above suggests a pair of neighboring tiles, which is the easiest swap to make by hand. Then solve the board with the sliding puzzle solver.
If you would like to finish the puzzle yourself once it’s fixed, read how to solve a sliding puzzle. It walks through the row-by-row method with a diagram for every key step.