Slide Puzzle Solver: 8-Puzzle & 15-Puzzle
Type the tiles of your sliding puzzle, use 0 for the empty space, and get a shortest solution with every move shown in order. Very scrambled 4×4 boards can hit the search limit.
How to use the slide puzzle solver
- Pick 3×3 for the 8-puzzle or 4×4 for the 15-puzzle.
- Type the tiles row by row, left to right. Use
0for the empty space. Spaces, commas or new lines all work. - Press Solve. Use Next and Back to see each move; the list says which tile to slide and which way.
The goal is 1, 2, 3 … in reading order with the empty space in the bottom-right corner.
Is my sliding puzzle solvable?
Only half of all tile arrangements can be solved. Count the inversions: pairs of tiles where a larger number comes before a smaller one when you read the board row by row, ignoring the blank.
- 3×3 (and any odd width): solvable when the number of inversions is even.
- 4×4 (and any even width): add the row of the blank counted from the bottom (1 = bottom row). Solvable when that total is odd.
Swapping any two tiles flips a board between the two halves, which is why a puzzle that was taken apart and reassembled sometimes cannot be finished. The solver checks this before searching.
Worked examples
Shortest solutions computed by this solver on November 2, 2026. Press Load to put a board in the solver above. “Positions searched” is how many board states the search expanded.
The second row is one of the two hardest 8-puzzle positions: every solvable 3×3 position can be solved in 31 moves or fewer, counting one tile slid one square as a move. A breadth-first search over all 181,440 solvable 3×3 boards, run in this page’s test suite, finds exactly two at 31 moves: this one and 6 4 7 / 8 5 0 / 3 2 1. For the 15-puzzle the proven maximum is 80 moves. These examples were picked to show different difficulties; the positions-searched count includes positions the search revisits.
How the solver finds the shortest solution
For the 3×3 puzzle it runs an A* search; for the 4×4 puzzle it runs IDA*, a memory-light version of the same idea. Both use the Manhattan distance (how far each tile is from its home square) plus a linear-conflict correction (two tiles in their home row or column but in the wrong order need extra moves). That estimate never overstates the remaining moves, so the first solution found is a shortest one. Very scrambled 15-puzzles can take too long in a browser; the solver stops at a fixed search limit instead of returning a longer, non-optimal answer.
Slide puzzle FAQ
What is the difference between the 8-puzzle and the 15-puzzle?
The 8-puzzle has eight tiles on a 3×3 board; the 15-puzzle has fifteen on a 4×4 board. The 8-puzzle has 181,440 solvable positions, while the 15-puzzle has more than ten trillion, which is why it is much harder to solve optimally.
Can every slide puzzle be solved?
No. Exactly half of all arrangements are unsolvable; use the inversion rule above or let the solver check.
Does it work for picture slide puzzles?
Yes, if the finished picture has its empty space in the bottom-right corner. Number the pieces 1 to 8 (or 1 to 15) in the order they appear in the finished picture, then enter the scrambled positions.
Prefer word puzzles? Try today’s Puzzico or the Word Solver.
Sources
- Johnson and Story (1879), “Notes on the ‘15’ Puzzle”, for the solvability rule.
- Reinefeld (1993), “Complete Solution of the Eight-Puzzle and the Benefit of Node Ordering in IDA*”, IJCAI, for the 31-move maximum.
- Korf and Schultze (2005), “Large-Scale Parallel Breadth-First Search”, AAAI, confirming the 80-move maximum first reported by Brüngger, Marzetta, Fukuda and Nievergelt (1999).