Free · runs in your browser

Sliding puzzle solver

Type in the tiles from your puzzle. The solver tells you whether it can be solved at all, then finds the optimal solution and plays it back.

Board

Type the numbers as they appear on your puzzle, reading left to right, top to bottom. Leave the empty cell blank or 0.

Tap a cell to edit it.

This position is solvable.

Inversions 47 + empty row from bottom 4 = 51. On an even-width board the total must be odd.

How the solver works

First it runs the parity test. Half of all tile arrangements can never be solved by sliding, and the test settles that in a fraction of a millisecond without searching anything. If your puzzle fails, no amount of moves will fix it; two tiles have to be physically swapped.

Then it runs IDA*, an iterative-deepening search guided by a Manhattan-distance heuristic with linear-conflict correction. The search is exact: the solution it returns is the shortest one that exists, not merely a good one. On a 3×3 board that takes milliseconds. On a 4×4 board a typical shuffle takes under a second and hard positions a few seconds; the very hardest 4×4 positions, which need 70 to 80 moves, can exceed the browser time limit.

The search runs in a background thread, so the page stays responsive, and nothing is sent to a server. Your position never leaves the browser.

Solver questions

Why does the solver say my puzzle is unsolvable?

Because sliding moves can only reach half of all arrangements. If a physical puzzle has been taken apart and reassembled, or two tiles were popped out and swapped, it lands in the unreachable half. The test: count the inversions in reading order; on a 4×4 add the row of the empty cell counted from the bottom starting at 1, and the total must be odd; on a 3×3 the inversion count alone must be even. The classic unsolvable example is a solved board with 14 and 15 swapped.

Is the solution really the shortest possible?

Yes. IDA* with an admissible heuristic is guaranteed to return an optimal solution when it finishes. The move count you see is the minimum number of single-tile slides for that position. The hardest 3×3 positions need 31 moves and the hardest 4×4 positions need 80.

Can it solve a 5x5 or larger puzzle?

Not optimally in a browser. The 5×5 puzzle has about 7.8 × 10²⁴ solvable positions and optimal solutions of 100 to 200 moves; exact search for that is a research problem, not a web page. For 5×5 and larger, use the row-by-row method from the guide: solve the top row and left column by hand, and what remains is a 4×4 that this solver handles.

How do I enter my puzzle?

Read your board left to right, top to bottom, and type each number into the matching cell. Leave the empty space blank. The verdict updates as you type, and the Solve button unlocks once every number from 1 to 15 (or 1 to 8) appears exactly once.