15 puzzle solver
Type your scrambled sliding tile board into the grid below, using 0 for the empty square, and this solver returns the move list that finishes it. It runs entirely in your browser, checks whether the board is mathematically solvable at all, and lets you step through the solution one slide at a time. Underneath there is the method for solving a 15 puzzle by hand, which is the part worth learning.
Enter your board
First: is your board even solvable?
A 4x4 sliding puzzle has a parity rule. Count every pair of tiles that appears in the wrong order reading left to right, top to bottom, then add the empty square's row counted from the bottom, where the bottom row is 1. If that total is odd the board can be solved; if it is even, no sequence of slides will ever finish it. This is why a physical puzzle that has had its tiles prised out and pushed back in can be permanently broken, and why the solver above refuses some boards instead of searching forever.
The layer method for solving by hand
Do not try to fix the whole board at once. Place tiles 1 to 4 across the top row, left to right, and once that row is correct never move it again — steer the empty square around it through the rows below. Do the same with tiles 5 to 8. When only the bottom two rows are left, stop working row by row: bring 9 and 13 into the left column together, then 10 and 14, then rotate the last three tiles into place. Nearly everyone who stalls on a 15 puzzle stalls because they keep breaking a finished row to rescue a later tile.
How the solver finds the shortest answer
The solver uses IDA* search: it guesses a minimum number of remaining moves, explores only sequences that could finish within that guess, and raises the guess when none do. The guess comes from adding each tile's straight-line distance from its home square, plus a penalty for pairs of tiles that share a row or column in the wrong order and must therefore move around each other. That estimate never overshoots, which is what makes the first solution it finds a shortest one. The hardest possible board needs 80 moves, and on those the browser switches to a faster search that trades a few extra moves for an answer you get in seconds.
A harder relative: block puzzles
A 15 puzzle is about order — every tile can eventually reach any square. Change the pieces so they have different lengths and can only move along their own axis, and you get a sliding block puzzle, where a piece may be locked in one row for the whole level and the puzzle becomes about space instead. That family is far less mechanical to solve, because there is no layer method to fall back on. Escape Grid is a free browser version with 160 hand-checked levels — no download and no account, and every level is guaranteed solvable because a solver verified it before release.
Related: the full sliding puzzle guide covers both puzzle families, and Klotski explained covers the classic block layout.
Frequently asked questions
- How does this 15 puzzle solver work?
- You type your scrambled board into the grid, using 0 for the empty square, and the solver searches for the shortest sequence of slides that reaches the ordered position. It runs entirely in your browser — nothing is uploaded — and it uses IDA* search with a Manhattan distance and linear conflict estimate, the standard approach for this puzzle.
- Is every 15 puzzle solvable?
- No. A 4x4 sliding puzzle is only solvable when the number of out-of-order tile pairs, plus the empty square's row counted from the bottom starting at 1, adds up to an odd number. Roughly half of all random shuffles fail that test and cannot be solved by sliding at all. The solver checks this first and tells you when a board is genuinely impossible.
- How many moves does a 15 puzzle take to solve?
- The hardest possible 4x4 position needs 80 single-tile slides, and a typical random shuffle needs somewhere around 50. If you are finishing in far more than that, you are almost certainly breaking rows you had already completed.
- How do you solve a 15 puzzle by hand?
- Solve it in layers. Complete the top row left to right, then the second row, and never move a finished row again — route the empty square around it through the rows below. When only the bottom two rows remain, stop working row by row and place those two rows together as pairs of columns.
- Why does the solver sometimes say a board is too complex?
- Finding the provably shortest solution can require searching an enormous number of positions. When a board exceeds the browser's search budget, the solver switches to a faster search that still returns a valid solution but may use a few extra moves, and it tells you when that happened.