Sliding puzzle solver facts at a glance
The sliding puzzle solver handles the 8 puzzle (3x3), the 15 puzzle (4x4) and the 24 puzzle (5x5). It checks first whether your board can be solved, then searches for the fewest moves (3x3 and 4x4) or solves it row by row (5x5). It is free, needs no account and runs in your browser.
| Puzzle sizes | 3x3 (8 puzzle, tiles 1 to 8), 4x4 (15 puzzle, tiles 1 to 15) and 5x5 (24 puzzle, tiles 1 to 24), one blank |
|---|---|
| Goal | Tiles in order row by row, blank in the bottom-right corner |
| Input | Tap a cell and a number, or type the numbers row by row with 0 or _ for the blank |
| Solvable check | Instant, by counting tiles that are out of order (and the blank's row on 4x4) |
| 8 puzzle | Always the fewest moves; no position needs more than 31 |
| 15 puzzle | The fewest moves when the exact search finishes within 6 seconds; otherwise a short solution, clearly marked as not proven fewest |
| 24 puzzle | A full solution, usually 140 to 200 moves, in about a second; not the fewest |
| What you get | Each move as a tile and a direction, such as “slide 7 left”, with a step-by-step replay |
| Price and setup | Free, no account, no download; a board link keeps the tiles in the link itself |
How to use the sliding puzzle solver
Pick 3x3 or 4x4, copy your tiles into the grid row by row with one blank, and press Solve: the list shows which tile to slide, and which way, for every move to the solved board.
- Pick the size. 3x3 is the 8 puzzle, 4x4 is the 15 puzzle and 5x5 is the 24 puzzle.
- Enter the tiles. Tap a cell, then tap its number; the next empty cell is selected for you. Tap Blank for the empty space. On a keyboard it is quicker to type all the numbers in reading order, such as 1 2 3 4 5 6 0 7 8, and press Fill grid.
- Press Solve. If a number is missing or appears twice, the solver says which one. If the board cannot be solved, it says why.
- Follow along. Each step reads like “slide 7 left”: move tile 7 one place to the left, into the empty space. Next and Back show the board after each move, and Play runs through them all.
- Keep the answer. Copy all moves puts the list on your clipboard, and Copy board link saves a link that reopens this board and solves it again.
8 puzzle solver (3x3)
The 8 puzzle has eight numbered tiles and one gap on a 3x3 board. Of its 362,880 arrangements, exactly half, 181,440, can be solved, and the solver always finds the fewest moves for them. On average a solvable position needs about 22 moves, and none needs more than 31. Only two positions need all 31: 8 6 7 / 2 5 4 / 3 _ 1 and 6 4 7 / 8 5 _ / 3 2 1.
15 puzzle solver (4x4)
The 15 puzzle has fifteen tiles on a 4x4 board, and 10,461,394,944,000 of its arrangements can be solved, again exactly half. A shuffled 15 puzzle usually needs about 50 to 60 moves, and the hardest positions need 80. The solver finds the fewest moves for most boards in under a second. A very hard board can take longer: after 6 seconds it stops the exact search and shows a short solution instead, marked as not proven fewest, along with the smallest number of moves the board could possibly need.
5x5 sliding puzzle solver (24 puzzle and puzzle boxes)
The 24 puzzle has twenty-four tiles on a 5x5 board, too many to search for the fewest moves in a browser. So the solver works like a fast human: tiles 1 to 5 in the top row, then 6, 11, 16 and 21 down the left column, then the 4x4 that is left goes to the 15 puzzle search. You get every slide, usually 140 to 200, labelled as not the fewest.
For a 5x5 picture slider such as a RuneScape puzzle box, number the pieces 1 to 24 in the order they belong in the finished picture, give the gap 0, and enter the board as it looks now.
Is my sliding puzzle solvable?
Half of all tile arrangements can never be solved, and you can tell which half by counting. Read the tiles row by row, skip the blank, and count the pairs that are out of order: every time a larger number comes before a smaller one, that is one inversion.
- 3x3: the puzzle can be solved only if the number of inversions is even.
- 4x4: add the blank's row, counting from the bottom (1 to 4). The puzzle can be solved only if the total is odd.
No slide can change these rules. The famous 14-15 puzzle has every tile in order except 14 and 15, which are swapped, and the blank in the bottom-right corner: that is 1 inversion plus row 1, an even 2, so it cannot be solved. If the solver says your board cannot be solved, the usual cause is two numbers copied the wrong way round, or two tiles of a real puzzle swapped after they were popped out.
How to solve a sliding puzzle by hand
You can solve any sliding puzzle by hand without search: finish the top row, then the next row, and leave the last two rows to be done column by column. The method below is for the 15 puzzle; it uses many more moves than the fewest, but it never gets stuck on a puzzle that can be solved.
- Place 1 and 2. Slide them into the top-left corner one at a time. Move the blank around a tile to walk it where it belongs, and do not disturb tiles that are already home.
- Place 3 and 4 together. The last two tiles of a row usually cannot go in one at a time, because placing one blocks the other. Put 4 where 3 belongs, then 3 directly below it, and bring the blank to 4's home in the corner. Slide 4 right, then slide 3 up: both drop into place.
- Do the second row the same way. Place 5 and 6 directly, then 7 and 8 with the same corner trick. The top two rows are now finished and never move again.
- Solve the last two rows column by column. For the left column, put 13 where 9 belongs and 9 just to its right, then bring the blank to 13's home. Slide 13 down, then slide 9 left. Do the same for 10 and 14.
- Turn the last square. Tiles 11, 12 and 15 and the blank are left in a 2x2 square. Cycle the three tiles around the square until they line up. If they never do, two tiles are swapped and the puzzle cannot be solved.
On a 3x3 board, do the top row with the corner trick for 2 and 3, then the left column (7 where 4 belongs, 4 to its right), then turn the last 2x2 square. On 5x5 and larger boards, finish the top row and the left column, again and again, until a 3x3 is left in the bottom-right corner.
How the solver works
The solver uses IDA*, a search that tries every sequence of moves up to a limit and raises the limit one step at a time, so the first solution it finds is the shortest. It skips hopeless sequences with an estimate that never overstates the moves left: tile distances plus row and column conflicts on 3x3, and on 4x4 pattern databases that bring each group of five tiles home from every possible placement, about half a million per group. If the exact search on a 4x4 board runs past 6 seconds, a faster search that is allowed to take a longer road gives a short solution instead.
Frequently asked questions
Why does the solver say my puzzle cannot be solved?
Exactly half of all tile arrangements can never reach the goal, whatever you slide. A puzzle that was shuffled by sliding can always be solved, so this message almost always means two numbers were entered the wrong way round, or two tiles of a real puzzle were swapped by hand.
Is it really the fewest moves?
For every 8 puzzle, yes. For a 15 puzzle, yes whenever the result says the fewest possible, which is the case for most boards. If the exact search does not finish within 6 seconds, the result says a short solution, not proven fewest, and gives the smallest number of moves the board could need.
What is the most moves an 8 puzzle or 15 puzzle can need?
An 8 puzzle never needs more than 31 moves, and only two positions need that many. A 15 puzzle never needs more than 80 moves.
Can I use it for a picture sliding puzzle?
Yes. Number the pieces by where they belong in the finished picture, 1 to 8 or 1 to 15 reading row by row, with the empty spot in the bottom-right corner. Then enter each piece's number where it sits now.
What if my puzzle's solved state has the blank in the top-left corner?
The solver always aims for the tiles in order with the blank in the bottom-right corner. A puzzle that should end with the blank first has a different goal, so the moves shown will not finish it.
How do I solve a 15 puzzle by hand?
Solve the top row, then the second row, placing the last two tiles of each row together: put 4 where 3 belongs and 3 below it, then slide 4 right and 3 up. Finish the bottom two rows column by column with the same trick, and cycle the last three tiles around the final 2x2 square.
Can it solve a 5x5 or larger sliding puzzle?
It solves 5x5 boards with a full solution, not the fewest moves. On 6x6 or larger, solve the top row and left column by hand until a 5x5 or smaller corner is left, number those tiles in order, and enter that corner here.
Is the sliding puzzle solver free?
Yes. It is free, with no account and no download, and it runs in your browser. A board link keeps the tiles in the link itself.