How to know if a 8 puzzle is solvable

An inversion is an unordered pair of distinct numbers, such as $\{5,7\}$, where the two numbers are not placed in the order they are supposed to be in the puzzle (in this case, listing the numbers row-by-row, $5$ comes after $7$, which makes this an inversion).

Each time you slide a tile horizontally, you neither create nor remove any inversions. Each time you slide a tile vertically, two pairs of numbers are changed from being an inversion to not being an inversion, or vice versa. Which is to say, for any move you make, the number of inversions either increases by $2$, decreases by $2$, or remains constant.

So no matter what you do, you cannot change the fact that you have an odd number of inversions, which means you can't get to a solved state.


Label the empty cell $9$. Then the above diagram represents the permutation $$(1\ 2\ 3\ 6\ 8)(4\ 5\ 9)(7).$$ The sign of this permutation equals $1$.

Every move consists of swapping the empty cell with an adjacent cell. The sign of this permutation is $-1$. So to get the desired permutation, you must perform an even number of swaps.

Color the board black and what like a chess board. With every swap the empty cell moves to a different color. So after an even number of swaps it ends up at the same color as where it started. But the two empty cells in the two pictures are at two different colors.