Skip to content

How to Solve a Sliding Tile Puzzle, Step by Step

Learn how to solve a sliding tile puzzle: a row-by-row method for 3x3 and 4x4 boards, a worked example, and a quick check for shuffles that can never be solved.

Want to know how to solve a sliding tile puzzle? You fix one tile, the next slide knocks it out of place, and ten minutes later you’re back where you started. Or the board was never solvable. Below: a row-by-row method for 3x3 and 4x4 boards that never undoes its own work, one 3x3 board solved move by move, and a 20-second check for whether a shuffle can be solved at all.

1. The goal and the one rule

The goal is to get the numbered tiles in order, with the empty square (the blank) in the bottom-right corner. A 3x3 board has tiles 1 to 8. A 4x4 board, often called the 15 puzzle, has tiles 1 to 15. The only move is to slide a tile next to the blank into the blank’s square.

Think about moving the blank, not the tiles. Every move here is a move of the blank: U, D, L or R, for up, down, left or right. So L means the blank moves left, and the tile on its left slides right.

Why does random sliding fail? Every slide shakes tiles you’ve already placed. Build in a fixed order instead.

2. How to solve a sliding tile puzzle: top row, left column, last block

Solve the board in three steps.

  • Step 1: the top row, tiles 1, 2 and 3.
  • Step 2: the left column, tile 4 and then tile 7.
  • Step 3: what’s left is a 2x2 block with 5, 6, 8 and the blank. Turn the three tiles round the block like a small roundabout until they’re in order.

Once a row or column is done, never move it again.

The first tiles of a row can go in any way you can find. The last two tiles of a row or column need a trick.

The same idea repeats on a 4x4, for the 3x3 that remains. There’s no 4x4 move list here.

A solved 3x3 sliding puzzle with the top row of tiles 1, 2 and 3 highlighted.
After step 1: the top row is done.
A solved 3x3 sliding puzzle with the top row and the left column highlighted.
After step 2: the top row and the left column are done.
A solved 3x3 sliding puzzle with the 2x2 block of 5, 6, 8 and the blank outlined in gold.
Before step 3: only the 2x2 block at the bottom right is left to solve.

3. The trick for the last two tiles of a row

The trouble starts when 1 and 2 are in place and you slide 3 into the corner: 2 gets pushed out again. The fix for the top row: park 2 in the top-right corner and 3 directly below it, with the blank between 1 and 2 in the top middle. Then move the blank R, so 2 slides left into place, and D, so 3 slides up. Tiles 1, 2 and 3 are home.

A 3x3 board set up for the trick: 1, a blank, then 2 on top, with 3 under the 2.
Before the trick: 2 is in the top-right corner, 3 is below it, and the blank sits between 1 and 2.
A 3x3 board with 1, 2 and 3 home in the top row after the trick.
After the trick: 1, 2 and 3 are home.

Walk the blank round the free squares to reach that shape; section 4 shows the moves.

The column version is the same trick on its side, for the left column once 1, 2 and 3 are home. Park 4 in the bottom-left corner, with 7 to its right and the blank directly above 4. Move the blank D, so 4 slides up, then R, so 7 slides left.

4. A 3x3 solved move by move

The start board has 12 inversions, an even count, so it’s solvable (section 5 explains why). The solution takes 19 moves.

The 3x3 start board, reading 4 1 8, 3 2 blank, 7 6 5.
The start board.

Stage 1, tile 1 home: L L U R (4 moves).

The board after four moves, with tile 1 home in the top-left corner.
After stage 1 (4 moves): tile 1 is home.

Stage 2, tiles 2 and 3: R D L U sets up the trick (4 moves), which leaves the board from section 3. Then R D, the trick itself (2 moves), finishes the top row after 10 moves.

The board after ten moves, with the top row 1, 2, 3 done.
After stage 2 (10 moves): the top row is done.

Stage 3, tiles 4 and 7: D L L U sets up the column trick (4 moves), and D R finishes it (2 moves). The left column is done after 16 moves.

The board after sixteen moves, with the top row and left column done.
After stage 3 (16 moves): the left column is done.

Stage 4, the last 2x2 block: U R D (3 moves). The tiles 5, 8 and 6 go round the block once.

The 3x3 board solved, every tile in order and the blank in the bottom-right corner.
Solved in 19 moves.

Shorter solutions exist for this board: 15 moves is possible. The method trades a few extra moves for never getting lost.

5. Can this shuffle be solved at all?

How many 3x3 shuffles can never be solved? Exactly half. Of the 362,880 ways to arrange the eight tiles and the blank, only 181,440 can be reached by sliding. Swap 7 and 8 on a solved board and you have the classic impossible puzzle.

The check: read the tiles left to right, row by row, ignoring the blank. Count the pairs where a bigger number comes before a smaller one; these are called inversions. Even count? Solvable. Odd? Not.

The start board from section 4 reads 4 1 8 3 2 7 6 5. Its pairs: 4 with 1, 3 and 2 (3); 8 with 3, 2, 7, 6 and 5 (5); 3 with 2 (1); 7 with 6 and 5 (2); 6 with 5 (1). That’s 12, even, so it’s solvable.

Why does that hold? A slide along a row leaves the count as it is, and a slide up or down changes it by 0 or 2, so an odd count can never turn even.

On a 4x4 (the 15 puzzle), add the blank’s row counted from the bottom (bottom row = 1) to the inversion count. An odd total is solvable:

  • The solved board: 0 inversions plus 1 is 1, odd, so solvable.
  • Tiles 14 and 15 swapped: 1 plus 1 is 2, even, so impossible.
  • Tiles 1 to 11 in order, the blank at the end of the third row, then 13, 14, 15, 12: 3 plus 2 is 5, odd, so solvable.

The rules in short:

  • 3x3: an even number of inversions means solvable.
  • 4x4: the inversions plus the blank’s row from the bottom must be odd.

6. Three boards to try: solvable or not?

Try each board before you open its answer. Count the inversions first.

Board A: a 3x3 board in order except that 8 and 7 are swapped.
Board A: solvable or not?
Show the answer

Not solvable. One inversion, 8 before 7: an odd count, so it can never be solved.

Board B: a 3x3 board reading 2 8 3, 1 6 4, 7 blank 5.
Board B: solvable or not?
Show the answer

Not solvable. There are 11 inversions, an odd count, so it’s impossible.

Board C: a 3x3 board reading 8 1 3, 4 blank 2, 7 6 5.
Board C: solvable or not?
Show the answer

Solvable. There are 12 inversions, an even count.

Bonus, on a 4x4:

A 4x4 bonus board with the blank in the bottom-left corner.
Bonus, a 4x4: solvable or not?
Show the answer

Solvable. There are 18 inversions, and the blank’s bottom row counts as 1: 18 plus 1 is 19, odd.

7. A little history, then put it to work

The craze for the sliding puzzle swept the United States and Europe about 1880. The 15 puzzle is often credited to Sam Loyd, a famous puzzle writer, mainly through a prize puzzle with 14 and 15 swapped, but historians doubt his claim to have invented it. That swapped board is impossible, as section 5 shows. The hardest 15 puzzle positions need about 80 moves, found by computer.

Working one small step at a time is the habit this method uses too. Read more in how to get better at logic puzzles. For something quicker, try brain teasers for a 5-minute break.

Now shuffle a real board, count the inversions first, then solve it.

Play a free game

←All posts