How to Use the 8-Puzzle Solver
- Copy the board. Read the three rows from left to right. Enter 0 where the empty square appears.
- Check all nine positions. Each number from 0 through 8 must appear exactly once.
- Select Find moves. The board is tested for solvability before a path is calculated.
- Follow the highlight. Move the highlighted tile into the blank, then advance to the next step.
A solved board reads 1 2 3 4 5 6 7 8 0. You can tap into the squares directly or use the keypad below the board.
What the Result Shows
Each step is one tile moving into the empty square. Next and Prev let you inspect the sequence at your own pace; Play animates the same moves, and Restart returns to the board you entered.
For 3×3 boards, the returned sequence is a shortest path to the standard goal. If more than one shortest path exists, the solver only needs to show one of them. How the search decides which move comes next is worked through in A* search for the 8 puzzle.
How the Solver Detects an Impossible Board
Ignoring the blank, read the tiles row by row and count each pair where a larger number appears before a smaller one. A 3×3 board can reach the standard goal when that inversion count is even.
This divides the 362,880 possible arrangements into two equal groups: 181,440 solvable positions and 181,440 positions that cannot cross into the goal group through legal slides. The check happens before the solver starts building a move sequence, so an impossible board comes back as an answer rather than a failed search.
Swapping any two tiles by hand flips that parity — which is exactly how the 14-15 puzzle made its name in 1880. On a 3×3 the same trick makes a board that looks finished but can never be completed.
Where to Go Next
If your puzzle is 4×4 instead of 3×3, use the 15 puzzle solver — the method of entering a board is the same, but the parity rule adds the blank's row. Want to work the board out by hand first? How to solve a slide puzzle walks through the row-and-column method, and the hardest 8 puzzle explains which 3×3 positions sit furthest from the goal.