Slide Puzzle Solver

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.

12346758

How to use the slide puzzle solver

  1. Pick 3×3 for the 8-puzzle or 4×4 for the 15-puzzle.
  2. Type the tiles row by row, left to right. Use 0 for the empty space. Spaces, commas or new lines all work.
  3. 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.

12346758
8-puzzle, a few moves out

Shortest solution: 2 moves · positions searched: 2

86725431
8-puzzle, hardest position

Shortest solution: 31 moves · positions searched: 3,881

652391117131041415128
15-puzzle, light scramble

Shortest solution: 20 moves · positions searched: 20

183611549214121371015
15-puzzle, medium scramble

Shortest solution: 30 moves · positions searched: 3,551

783265411014121311159
15-puzzle, heavier scramble

Shortest solution: 40 moves · positions searched: 260,848

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