How to Solve the Last Two Rows of a Sliding Puzzle
Why the last two rows of a sliding puzzle feel stuck, the column-by-column pair method that solves them, and how to escape the position that traps everyone.
Most players can solve the top rows of a sliding puzzle. The trouble starts when two rows are left: tiles that were easy to place suddenly refuse to go in without knocking out their neighbours. This guide explains why, and gives you a method that works every time.
It picks up where How to Solve a Sliding Puzzle, Step by Step leaves off. Every board here is playable, and Show solution plays the shortest possible solution, found by computer.
Why the last two rows are different
With three or more rows left, there is plenty of spare room to park tiles while you work. With two rows left, room is tight, and finishing one more row would leave none at all.
Suppose you finished the third row of a 4 × 4 board. Only the bottom row would be left, and the gap could only travel along it. Tiles in a single row can slide left and right, but they can never pass each other, so their order can never change. Unless the bottom row happened to be in order already, you would have to break the row you just built.
The way out is to stop working in rows. Solve the last two rows column by column, from left to right, placing the top and bottom tile of each column together. Each finished column leaves a smaller two-row block to its right, which you solve the same way.
The pair move
On a 4 × 4 board the first pair is 9 (top) and 13 (bottom). Why not place 9 first and then 13 under it? Once 9 is in place, the bottom-left corner becomes a dead end: the gap can only get in from the right, so whatever tile sits in the corner can only step out and back in again. Getting 13 into it would mean moving 9 again. So place them as a pair:
Put the bottom tile, 13, in the top tile's home, where 9 belongs.
Put 9 right beside it, in the second column of the same row.
Bring the gap to the bottom-left corner.
Slide 13 down, then 9 across. The column is done.
0 moves
While you set up the pair, keep the gap in the bottom two rows, in the column you are working on and the ones to its right. That is your workspace: you can move tiles around in it as much as you like without touching the finished rows above.
Getting 13 and 9 into position
Steps 1 and 2 are where the moves go. A few habits keep them short:
Place the bottom tile first. Bring 13 to 9's home before you worry about 9. Moving a tile along a two-row strip works like moving it anywhere else: walk the gap around to the side you want it to go, then slide it in.
Bring the top tile in from the right. Route 9 through the workspace, then up or across into the spot beside 13.
Keep 9 away from the bottom-left corner. With 13 in place, you can always bring 9 beside it without moving 13 again, with two exceptions: 9 is in that corner, or 9 is right next to it with the gap in the corner (its only move is into the corner). The second one catches people out when they slide 13 up from the corner into place while 9 sits beside it. Either way, you are in the trap below.
Leave the finished columns alone. Once a column is solved, the gap never needs to enter it again.
The trap: the top tile under the bottom one
Sooner or later you will meet this position: 13 is in 9's home as planned, but 9 is stuck directly underneath it, in the bottom-left corner. The pair move can't fix it, because 9 is in the very spot 13 needs.
0 moves
Taking 9 out of the corner is not enough on its own. We checked every possible trap position by computer, all 360 of them: with 13 left in 9's home, there is no way to get 9 beside it. 13 has to come out too:
Move 13 out of 9's home and 9 out of the corner, into the workspace to the right.
Set up the pair again: 13 into 9's home first, then 9 beside it, this time keeping 9 out of the corner.
Finish with the pair move.
It costs moves. Even played perfectly, getting from the trap to a finished first column takes 17 moves on the board above, and up to 19 from other trap positions. But it always works.
Now press Show solution on the board above. The shortest solution, 19 moves, does something the method never does: it briefly lifts 5, 6 and 7 out of the finished row above, uses the extra room, and puts them back. Borrowing a finished row is perfectly legal, but here it only saves two moves: without it, the best possible is 21.
The next columns
With the first column done, the rest of the board is a smaller version of the same problem: two rows and fewer columns. Repeat the pair move for 10 and 14, and so on for any further columns, until a 2 × 2 corner is left. The same trap waits one column further along, with 10 under 14, and the same fix gets you out. Sometimes a column is almost right already and a few slides finish it:
0 moves
The last corner
When two columns are left, the last three tiles and the gap share a 2 × 2 block. Turn them around the gap in one direction and keep going: within a few turns they drop into order.
0 moves
If they go round and round but two of them always stay swapped, the board can't be solved. That never happens with the levels on this site, which have all been solved by computer.
On 3 × 3 and 5 × 5 boards
The method doesn't change with the size of the board, only how many rows you solve first and how many columns you pair:
| Board | Rows solved first | Columns to pair | Then |
|---|---|---|---|
| 3 × 3 | 1 | 1 (4 and 7) | 2 × 2 corner |
| 4 × 4 | 2 | 2 (9 and 13, 10 and 14) | 2 × 2 corner |
| 5 × 5 | 3 | 3 (16 and 21, 17 and 22, 18 and 23) | 2 × 2 corner |
On a 3 × 3 board the last two rows are just a 2 × 3 block: one pair, then the corner.
0 moves
Practise the whole thing
This board has the top two rows solved and the last two rows fully mixed up. Work through it column by column: 9 and 13, then 10 and 14, then the corner. The shortest solution takes 28 moves. Don't worry if the method takes twice that: reliable comes first, short comes with practice.
0 moves
When it feels easy, try it on a real level, where you set up the top rows yourself:
Play Level 194 × 4 · solvable in 24 moves