How to Solve a Sliding Puzzle

Any sliding block puzzle can be solved with one simple plan: finish the board a row at a time from the top, then the last two rows a column at a time. The only trick you need is how to bring in the last two tiles of a line. This guide uses the classic 4×4 15 puzzle, and the same method works on the 8 puzzle and the 24 puzzle.

Think about the gap

You never really move a tile on its own: you move the gap, and tiles step into it. To move a tile one square left, first walk the gap round to the square on its left, without disturbing tiles you've already placed, then slide the tile in. Repeat, and a tile can travel anywhere on the board. Everything below is this one idea used with a plan.

Step 1: the top row

Place 1 in the top-left corner, then 2 next to it. Those two are easy: move each one along the row and up, a step at a time.

The last two tiles of the row, 3 and 4, are where most people get stuck: put 3 in place first and there's no room left to bring 4 into the corner without knocking 3 out again. So bring them in together:

  1. Park 4 where 3 belongs.
  2. Park 3 directly below it.
  3. Walk the gap round to the top-right corner (through the second row, not through the top row).
  4. Slide 4 right, then slide 3 up.
Set-up: 4 waits where 3 belongs, 3 is right below it, and the gap is in the corner.
Slide 4 right, then 3 up. The top row is done.

Step 2: the next rows

Do exactly the same for the second row: place 5 and 6, then bring 7 and 8 in together with the same set-up. From now on, never move a tile in a finished row. On a 4×4 board, stop when only two rows are left; on bigger boards keep going row by row until two rows remain.

Step 3: the last two rows, column by column

With two rows left there's no room to work row by row, so turn the trick sideways and finish one column at a time, starting on the left. For the first column, 9 and 13:

  1. Park 13 where 9 belongs.
  2. Park 9 just to its right.
  3. Bring the gap to the square below 13.
  4. Slide 13 down, then slide 9 left.
Set-up for the first column: 13 waits where 9 belongs, 9 is beside it and the gap is below 13.

Then do the same for the next column, 10 and 14.

Step 4: the last square

Three tiles are left in the bottom-right 2×2 square: 11, 12 and 15. Move the gap round and round that little square, always in the same direction. The three tiles take turns rotating, and within a few laps they line up.

The last square: keep circling the gap the same way until 11, 12 and 15 click into place.

If they never line up, with two tiles stuck swapped however long you circle, the puzzle was never solvable in the first place. That only happens with physical puzzles whose tiles have been popped out and put back. Here's how to check.

3×3 and 5×5 boards

The 8 puzzle (3×3) is the short version: solve the top row (1, then 2 and 3 together), then the left column (4 and 7 together), then circle 5, 6 and 8 around the last square. Play the 8 puzzle.

The 24 puzzle (5×5) shrinks one step at a time: the top row (1 to 5) and the left column (6, 11, 16, 21) leave a 4×4 square, which you solve like a 15 puzzle. Play the 24 puzzle.

How to tell if a sliding puzzle is solvable

Exactly half of all arrangements of a sliding puzzle can be solved. To check one:

  1. Read the tiles row by row from the top-left, skipping the gap.
  2. Count the inversions: every pair where a bigger number comes before a smaller one.
  3. Odd-width boards (3×3, 5×5): the puzzle can be solved when the number of inversions is even.
  4. Even-width boards (4×4): count the gap's row from the bottom (the bottom row is 1). The puzzle can be solved when inversions plus that row number is odd.

Try it on Sam Loyd's famous "14-15 puzzle", a solved 15 puzzle with 14 and 15 swapped: there's one inversion (15 before 14) and the gap is in row 1 from the bottom. 1 + 1 = 2, which is even, so it can't be solved, and no amount of sliding will ever fix it. We checked this rule by computer against every possible position of the 2×2, 2×3, 2×4 and 3×3 boards. Every puzzle on Sliding Block passes it, so it can always be solved.

Solving in fewer moves

Questions

What's the easiest way to solve a sliding puzzle?

Solve it row by row from the top, bringing the last two tiles of each row in together, then finish the last two rows column by column and rotate the final three tiles into place.

Why are my last two tiles swapped?

Because that position can't be solved. It happens when the tiles of a physical puzzle are taken out and put back in the wrong order. Swap the two tiles by hand and it will solve normally. Puzzles in Sliding Block are always solvable.

How long does it take to learn?

Less time than it looks. Once the last-two-tiles trick makes sense, the 8 puzzle becomes easy, and the 15 and 24 puzzles are the same idea with more tiles. Speed comes with practice.

Practice now

Start on 3×3, then step up when it feels easy.

Moves 0 Time 0:00

Tap a tile next to the gap, or use the arrow keys.

Sliding Block on iPhone: a 4×4 puzzle of soft pastel keycaps numbered 1 to 15 with one empty slot.

Sliding Block for iPhone

The sliding puzzle, made to feel wonderful

  • Soft keyboard keycaps that slide with a satisfying, creamy click.
  • Classic levels on 3×3, 4×4 and 5×5 boards, from easy to expert.
  • Speed Run: race the clock on a fresh board.
  • 16 keycap sets to collect: five to start, seven more to unlock by playing, four premium.
  • Hints that light up the right key when you're stuck. Three are free.

Free to play · Optional in-app purchases · Works offline