Can Every 15 Puzzle Be Solved? The Parity Rule Explained

15 Puzzle
15 Puzzle - classic 4x4 sliding tile puzzle, always generated solvable. Free, no signup.

In 1880, a craze swept the United States over a tiny sliding wooden puzzle where tiles 14 and 15 were swapped. A prize was offered for anyone who could slide them back into order. Nobody ever collected it, because no sequence of legal moves can reach that state.

Why sliding moves can never reach the other half

Read the board row by row from left to right and count every pair of tiles where a larger number appears before a smaller one. That count is called the number of inversions. Now note which row the blank space sits on, counting from the bottom (row 1 is the bottom row).

  • Sliding a tile horizontally does not change the order of numbers at all, so inversions stay unchanged.
  • Sliding a tile vertically moves it past three other tiles, which always changes the inversion count by an odd number (+3, +1, -1, or -3) and shifts the blank row by 1.
  • Therefore, (inversions + blank row from bottom) never changes from even to odd or from odd to even.

How to check any 4x4 board

In the solved state (1 through 15 in order, blank in the bottom-right corner), inversions = 0 and blank row from bottom = 1. Their sum is 1, which is odd. Any board whose (inversions + blank row from bottom) is odd is solvable; if the sum is even, it is impossible.

That is why swapping just 14 and 15 breaks the puzzle: inversions jumps from 0 to 1 while the blank stays on row 1, making the sum 2 (even). No legal sequence of slides can ever undo a single swap.

Common questions

Why can you not swap 14 and 15 in a 15 puzzle?

Swapping two tiles changes the inversion count by 1 (odd) without moving the blank, which puts the board into the unreachable parity half.

What is the maximum number of moves needed to solve any solvable 15 puzzle?

80 single-tile moves. That number was proved in 2005 by exhaustive computer search.

Does the same rule apply to the 8-puzzle (3x3)?

Almost: on an odd-width grid (3x3), vertical moves skip two tiles (even), so inversions alone must be even for the board to be solvable.