How to Solve a Sliding Puzzle, Step by Step
A reliable layer-by-layer method for any sliding tile puzzle, from the 8 puzzle (3×3) to the 15 puzzle (4×4) and 5×5, with boards to practise on as you read.
You don't need to memorise long move sequences to solve a sliding puzzle. One method works on every size, from the 3 × 3 "8 puzzle" to the 4 × 4 "15 puzzle" and beyond: solve the board in layers, so that tiles you have finished never need to move again. A couple of small tricks handle the awkward moments.
Every board on this page is playable. Click or tap a tile in the same row or column as the gap to slide it. Show solution plays the shortest possible solution, found by computer. On the short demos it follows the method exactly, so you can watch each trick in action; on the full board near the end it takes its own shortcuts.
The goal
The solved board reads in order from the top left, row by row, with the gap in the bottom-right corner. On a 4 × 4 board that is 1 to 4 on the top row, 5 to 8 on the second, and so on, ending with 13, 14, 15 and the gap.
A tile can only move into the gap, so think of every move as moving the gap. Clicking a tile further along the same row or column pushes all the tiles in between, and each tile that slides counts as one move.
The method in brief
Solve the top row, left to right.
Solve each following row the same way, until only two rows are left.
Solve the last two rows column by column, from left to right.
Finish the last 2 × 2 corner by cycling its tiles around the gap.
On a 3 × 3 board, step 2 is skipped: after the top row, only two rows remain.
Step 1: Solve the top row
Bring tile 1 to the top-left corner, then tile 2 next to it, and so on. To move a tile, walk the gap around to the side you want the tile to go, then slide the tile into it. Once the gap is in front of a tile, each further step in a straight line takes five moves: one to slide the tile, four to bring the gap around to its front again.
Two habits keep this efficient:
Move the gap, not the tile. Before each move, ask where the gap needs to be next.
Go around finished tiles, never through them. Route the gap along the side away from the tiles you have placed.
The last two tiles of a row
The first tiles of a row are easy, but the last two can't simply go in one after the other. Once the second-to-last tile is in place, the last tile's corner becomes a dead end: the gap can only reach it from below, so whatever tile sits there can only step out and back in. Instead, place them as a pair:
Put the second-to-last tile (3 on a 4 × 4 board) in the corner, where the last tile belongs.
Put the last tile (4) directly below it.
Bring the gap to the second-to-last tile's home, then slide that tile across and the last tile up behind it.
0 moves
If the last tile reaches its corner early, while the second-to-last is still elsewhere, move it out again first. With 4 in its corner, 3's home becomes the dead end instead, and 3 can't get in.
Step 2: Repeat, row by row
Solve the second row exactly like the first, using the same trick for its last two tiles. Keep going until two rows are left: after one row on a 3 × 3 board, two rows on a 4 × 4 board and three on a 5 × 5 board.
Sometimes a whole row is only one place off. Then a few slides fix it at once:
0 moves
Step 3: The last two rows, column by column
With two rows left there is no room to solve them one at a time. Turn the method sideways instead: solve them column by column, from left to right, placing the top and bottom tile of each column as a pair. On a 4 × 4 board the first pair is 9 and 13.
It is the same idea as the row trick, turned on its side:
Put the bottom tile (13) in the top tile's home, where 9 belongs.
Put the top tile (9) right beside it.
Bring the gap to the bottom-left corner, then slide 13 down and 9 across into place.
0 moves
Repeat for the next column until only a 2 × 2 corner is left. For why the last two rows work this way, and how to escape the position that traps everyone, see How to Solve the Last Two Rows.
Step 4: Finish the last corner
The last three tiles and the gap share a 2 × 2 block. Turn them around the gap in the same direction, clockwise or anticlockwise, and keep going: within a few turns they drop into order.
0 moves
If the three tiles go round and round but two of them always stay swapped, that position can't be solved. It never happens on this site, where every level has been solved by computer, but it can on a physical puzzle whose tiles were taken out and put back.
Put it all together
Here is a full 3 × 3 board to try the whole method on: the top row, then the left column as a pair, then the last corner. It is as hard as a 3 × 3 board gets: the best possible solution takes 31 moves. Of the 181,440 positions you can reach by sliding a 3 × 3 board, only two need that many. The method will take more moves, and that's fine.
0 moves
Tips for fewer moves
Look one tile ahead. While you route the gap to place one tile, nudge the next tile closer to its home if it costs nothing extra.
Prepare the pair early. While you place the first tiles of a row, steer its last two towards the right-hand end, so setting up the pair takes only a few moves.
Bring tiles in along the free side. Approach a tile's home from the unsolved part of the board.
Fastest or fewest? Speed comes from a smooth rhythm; fewest moves comes from planning. The game keeps a leaderboard for each, so pick your challenge.
Practise on a full board
The first 4 × 4 level is a good place to use every step of the method:
Play Level 194 × 4 · solvable in 24 movesEvery level on the game page has a known best solution, and you earn three stars by finishing close to it. Questions about moves, stars or saved progress are answered in the FAQ.