Sliding Puzzle Solver
Enter any 3x3 or 4x4 (15-puzzle) layout to check solvability and watch an instant step-by-step animated solution powered by A* and IDA*.
Click two tiles (or a tile and the empty slot) to swap them until the board matches your puzzle, then press Solve Puzzle.
Practice or Play After Solving
How to Use the Sliding Puzzle Solver
Our sliding puzzle solver takes any scrambled 3x3 (8-puzzle) or 4x4 (15-puzzle / 15 Klotski puzzle) board and produces a clear, animated, step-by-step move sequence right in your browser. Everything runs locally on your device in milliseconds—no signup and no waiting on remote queues.
- Choose your grid size: Select 3x3 (8-Puzzle) or 4x4 (15-Puzzle) in the control panel.
- Match your real board: Click any two tiles on the solver grid to swap them until the numbers match your puzzle, or type/paste your board row by row into the text box (use
0for the empty space, for example1 2 3 4 5 6 7 8 9 10 12 0 13 14 11 15) and click Apply. - Check solvability instantly: The Parity indicator checks your arrangement live. If two tiles are swapped into an impossible parity, the solver warns you immediately and offers a one-click Fix Unsolvable Parity button.
- Click Solve Puzzle: Within a fraction of a second, the solver generates the complete move list. Use Play Steps (at Slow, Normal, or Fast speed), step forward/backward with Prev / Next, or click any individual move in the list to jump directly to that frame.
How the Solver Algorithm Works (A-Star & IDA-Star)
Solving a 3x3 board involves at most 181,440 reachable states, so our 3x3 sliding puzzle solver runs exact A* search with Manhattan Distance + Linear Conflict to guarantee the mathematically shortest possible path (never exceeding 31 moves) in just a few milliseconds.
A 4x4 15-puzzle solver is vastly larger—over 10.46 trillion solvable configurations exist. Naive breadth-first search runs out of browser memory almost immediately. To keep solutions both fast and responsive inside a normal web tab, this solver uses a two-stage strategy:
- Stage 1 — Exact
IDA*(Iterative Deepening A-Star): Uses Manhattan Distance combined with row and column Linear Conflict penalties (an admissible heuristic that detects pairs of tiles blocking each other in their destination line). Most practical 20-to-48-move scrambles solve to the exact optimal move count in under 250 milliseconds. - Stage 2 — Fast Weighted
A*Fallback: For unusually deep 55-to-80-move scrambles where exactIDA*would otherwise stall a browser tab, the solver smoothly switches to WeightedA*to return a clean, verified step-by-step path in under half a second without freezing your screen.
How to Check If a Sliding Puzzle Is Unsolvable
Before blaming your strategy on a stubborn physical puzzle or mobile minigame, verify whether the layout is even solvable. Count the inversions—every pair of numbered tiles where a larger number appears before a smaller number when reading the grid left-to-right, top-to-bottom (ignoring the blank space):
- On a 3x3 board (odd width): The puzzle is solvable if and only if the inversion count is even.
- On a 4x4 board (even width): Count the blank slot's row from the bottom (
1for the bottom row up to4for the top row). The puzzle is solvable if and only ifinversions + blankRowFromBottomis odd.
For instance, the famous unsolvable 14-15 swap on a 4x4 board has 1 inversion (15 before 14) and the blank in bottom row 1, giving 1 + 1 = 2 (even)—proving no legal sequence of slides can ever solve it.
Solving Picture Puzzles & 15 Klotski Puzzles
Playing a picture-based sliding tile minigame or a 15 Klotski puzzle where the pieces show artwork instead of numbers? Mentally number the target picture from 1 to 8 (for 3x3) or 1 to 15 (for 4x4) left-to-right, top-to-bottom, with 0 for the empty corner. Enter where each numbered piece currently sits into this solver, then follow the animated moves on your game screen one step at a time.
Ready to practice solving on your own without assistance? Jump back to our Sliding Tile Puzzle, drill fast patterns on the 3x3 Sliding Puzzle, test your speed on the 15 Puzzle Online, or learn the human row-by-row method in How to Solve a Sliding Puzzle.
Sliding Puzzle Solver FAQ
Does this sliding puzzle solver support both 3x3 and 4x4 boards?
Yes. Switch between 3x3 (8-puzzle) and 4x4 (15-puzzle / 15 Klotski puzzle) at the top of the solver panel. Both sizes support click-to-swap editing, text input, parity verification, and animated step playback.
Why does the solver say my board is unsolvable?
Because exactly half of all tile arrangements are mathematically unreachable through legal slides. If your parity indicator says Unsolvable, double-check that you entered each tile in the right slot—or, on a physical puzzle, check whether two pieces were accidentally swapped when reassembled.
Does the solver always find the shortest possible solution?
For 3x3 boards, the solver always returns the guaranteed shortest (optimal) sequence using exact A*. For 4x4 boards, it runs exact IDA* first for optimal solutions on typical scrambles and falls back to fast Weighted A* on extreme scrambles so your browser never freezes.
Can I use this solver for picture sliding puzzles in video games?
Yes. Number the pieces of your target picture from 1 to 15 (or 1 to 8 for 3x3) from top-left to bottom-right, enter their current positions into the solver using 0 for the empty space, and follow the animated arrow directions.
Can I send my current game directly to the solver?
Yes. Whenever you are playing a 3x3 or 4x4 board on this website, click the Open in Solver button beneath the tray to transfer your exact board state straight into the solver automatically.