THE GUIDE · TAKE IT ONE TILE AT A TIME

How to Solve a Sliding Puzzle

A scrambled board looks like many problems at once. Give each tile a job, protect the work you have finished, and the next move becomes a little clearer.

Start with the goal, not the scramble

The standard goal is ascending numbers in reading order, with the empty square in the bottom-right corner. Only tiles touching the gap along an edge can move. Diagonal slides and lifting tiles out of the frame are not legal moves.

Think of the blank as your working space. To move a particular tile, first bring the gap next to it. You will often move other tiles temporarily to route the blank around your target. That is part of the method, not a sign that you are going backward.

The row-by-row method

Work from the top edge down, finishing the first rows while leaving the last two for later. Within a row, place tiles from left to right, but plan the final two tiles together. Once a row is finished, keep all subsequent moves below it.

Place the early tiles

Bring the next tile toward its target one step at a time. Route the gap through the unfinished area so that each slide moves the target in the direction you need. On a 3×3 board, first place tile 1. On a 4×4 board, place 1 and then 2 before arranging the last pair.

Finish the last two as a pair

Trying to place the last tile alone can trap its neighbor. For a row whose final two tiles are A and B, arrange A in the rightmost square of the target row and B directly below it, with the blank immediately left of A. Slide A left, then B up. The row is complete. Set up this pattern using the unfinished space below; if the pair is trapped, move it back into that space and try again.

For the first row of a 3×3, the pair is 2 and 3. The staging pattern across the top is “1, blank, 2”, with 3 immediately below 2. Slide 2 left, then 3 up.

Finish the last two rows together

When two rows remain, change direction. Solve vertical pairs from left to right instead of attempting another complete horizontal row. This preserves enough space for the blank to move around the remaining tiles.

Place a column pair

Suppose the next column needs A above B. Stage B in the top cell of that column, A directly to its right, and the gap below B. Slide B down, then A left. Those two tiles are now finished. Keep later moves to their right and repeat until only a 2×2 square remains.

Cycle the final square

Move the blank around the four-cell loop until the last three tiles reach their goals. For a solvable board with all earlier tiles correct, a rotation of this loop will finish the puzzle. If exactly two tiles are reversed with the blank already home, recheck the original layout and parity.

Adapt the method to 3×3, 4×4 and 5×5

How to solve a 3×3 sliding puzzle

Finish the top row, then immediately work on the remaining two rows. Place 4 above 7 in the leftmost column. The final 2×2 contains 5, 6, 8 and the blank; cycle it to finish. Do not lock the entire second row independently, because that removes the space you need to arrange the bottom row.

How to solve a 4×4 sliding puzzle

Complete the first two rows, using a pair for each row’s last two tiles. In the lower two rows, finish 9 above 13, then 10 above 14. The remaining 2×2 contains 11, 12, 15 and the blank. A methodical hand solution may be longer than the shortest possible route, and that is fine.

How to solve a 5×5 sliding puzzle

Finish the first three rows, then arrange column pairs in the last two. Larger boards are still solvable by hand with this method. The challenge is tracking more pieces without disturbing completed areas; optimal computer searches become expensive much sooner than the hand method becomes impractical.

Why some shuffles can never be solved

Write the numbers in reading order, ignoring the gap. An inversion is a pair in which a larger number appears before a smaller one. Count all such pairs, not just adjacent ones.

  • Odd-width boards, including 3×3 and 5×5: the inversion count must be even.
  • Even-width boards, including 4×4: add the inversion count to the blank’s row counted from the bottom, starting at 1. The sum must be odd.

These tests assume the standard bottom-right-blank goal. Swapping only two numbered tiles changes solvability. In contrast, shuffling by legal slides always preserves it. The Sliding Puzzle Solver checks this before it starts a search.

Odd-width example: two swapped tiles

21345678·
The only inversion is 2 before 1. One is odd, so this 3×3 board cannot reach the standard goal by legal slides.

Even-width example: the blank’s row matters

1234567891011·13141512
There are three inversions: 13, 14 and 15 each come before 12. The blank is in row 2 from the bottom. Since 3 + 2 = 5 is odd, this board is solvable: slide tile 12 up to finish it.

Try a two-move example

Start with this small layout. Tile 5 is below its target, and 8 is next to the empty destination in the bottom row:

1234·6758

Slide tile 5 up into the gap. Then slide tile 8 left. The board is solved. Notice that the blank moved down and then right, opposite to each tile’s direction.

For a more involved example, Play the sliding block puzzle and use Shuffle. Try placing the first row yourself, then compare your choices with the solver’s playback. The aim is to recognize useful setups, not to memorize an entire move list.

GOOD QUESTIONS

Frequently asked questions

Should I solve every row separately?

Stop solving individual rows when only two remain. Finish those two rows together, arranging a vertical pair at the left, then working toward the final 2x2 square. On a 3x3 puzzle, this happens immediately after the first row.

Can a 5x5 puzzle be solved by hand?

Yes. The same row-and-column strategy scales to larger square boards. It takes patience and more moves, but a large board does not make the method impossible. Finding a shortest solution is a much harder task than finding any solution.

What if only two tiles appear to be swapped?

If all other tiles, including the blank, are in their goal positions, swapping exactly two numbered tiles makes the arrangement unsolvable. Check your copied layout before trying to repair the final pair with more moves.