Sliding Block Puzzles: Clear the Blocker Chain, Free the Target

This article was written with AI and may contain mistakes. Found one? Tell us.

By Riddle10 Editorial Published 12 min read

To solve a sliding block puzzle, start from the target block and work backwards: find which pieces stand between it and the exit, then which pieces stand in the way of those, and clear that chain from its far end. Count the empty cells, tuck small pieces into far corners, and picture the position just before the target slides out.

This guide covers the pieces and how they move, a six-step method, a fully worked tray, the parking-style variant with its own small puzzle, a short look at how computers search for the fewest moves, and a practice tray with its answer.

What is a sliding block puzzle?

A sliding block puzzle is a flat, closed tray packed with rectangular pieces and a few empty cells. You may slide a piece into empty space, but you may never lift it, turn it or hop it over another piece. One piece is marked as the target, and the aim is to bring it to a gap in the tray wall, called the exit.

The pieces come in different sizes, and that is what sets this kind of puzzle apart. Only the target has a fixed destination. Every other piece simply has to be out of the way at the right moment, so you are not sorting the tray, you are opening a road through it.

In this guide, one move means sliding one piece in a single straight line, by as many empty cells as you like. You could instead count every cell of travel as a move. Under that rule the worked tray below needs 13 moves instead of 7, so always check which count a puzzle uses before comparing move totals.

How do the different piece sizes behave?

Piece shape decides where a piece can go. A big piece needs a whole row or column of space opened at once, while a small square can slip through any single empty cell.

PieceCellsSpace it needs to step sidewaysSpace it needs to step up or downUsual role
1x1 square1one empty cellone empty cellFiller that is easy to park in a corner
1x2 bar, lying flat2one empty celltwo empty cells side by sideA lid sitting right above or below the target
2x1 bar, standing2two empty cells, one above the otherone empty cellA wall beside the target route
2x2 square4two empty cells, one above the othertwo empty cells side by sideUsually the target, and the hardest piece to shift

The table hides one simple rule. The 2x2 target needs a matching pair of empty cells in front of it before it can move at all. Much of the work is building that double gap exactly where the target needs it.

How is it different from the numbered tile puzzle?

The numbered tile puzzle puts equal square tiles in a grid with one empty space, and each move pushes a neighbouring tile into that space. A paper published on 10 July 2015 points out that finding the fewest moves for the general square version had already been proved NP-hard, which means nobody knows a quick recipe that works for every size [1].

A block tray works differently, and the table compares the three puzzle styles in this guide.

FeatureNumbered tile puzzleBlock tray puzzleParking block puzzle
Piece sizesAll the sameMixed, from 1x1 to 2x2Bars two or three cells long
Directions a piece may slideAny, into the single gapAny of the fourOnly along its own length
Empty spaceA single cellA few cellsMany scattered cells
GoalEvery tile in orderOne target at the exitOne marked bar out through the exit
Main skillOrderingOpening a double gapTracing a chain of blockers

What is the step-by-step method?

  1. Mark the goal. Note the cells the target must cover at the very end, beside the exit. Every other decision serves those cells.
  1. Find the blocker chain. List the pieces that sit in the goal cells or on the target path. For each one, ask where it could go and which piece stops it. Keep asking until you reach a piece that can move right now. That piece is where you begin.
  1. Count the free cells. Note how many empty cells there are and where they sit. The target moves only when its whole leading edge faces empty cells, so plan where each pair of empty cells will be.
  1. Move the smallest pieces first, and move them far. Among the pieces in the chain, start with the small ones. A 1x1 square pushed all the way into a far corner stays out of trouble. Slide pieces as far as they go, unless that closes a gap you still need. Move the target early only when that move opens space the chain needs.
  1. Think in positions, not moves. Picture the position one move before the end: the target right beside its goal cells, with empty cells in front of it. Then ask what the position before that must look like. A few positions backwards often show the whole plan.
  1. Never undo without a reason. A move that reverses the last one wastes two moves. If you feel the urge, return to step 2 and look for another chain.

How does the method solve a four by four tray?

Here is an original tray to work through. Row 1 is the top row and column 1 is on the left. X is the 2x2 target. A is a flat bar, B is a single square, and C and D are standing bars. A dot marks an empty cell.

Col 1Col 2Col 3Col 4
Row 1XXCD
Row 2XXCD
Row 3AA··
Row 4B···

The exit is a gap in the bottom wall under columns 2 and 3, so X must finish on rows 3 and 4 of those columns. A computer search through every reachable arrangement of this tray confirms that 7 moves is the fewest possible. Try it before reading on.

Step 1: mark the goal. The goal cells are rows 3 and 4 of columns 2 and 3. Right now X cannot move at all. The tray walls sit above it and to its left, A sits under it and C sits beside it.

Step 2: find the blocker chain. X has to drop, and A and B lie beneath it. Both can slide right into empty cells, so they begin the chain. After X drops it will sit in columns 1 and 2, one column short of the goal.

X must then shift right, which needs column 3 empty on rows 3 and 4. If B slides all the way to column 4, only A is left in column 3, so A must later go up.

The cells above A belong to C and D. Neither can rise. Dropping C would put it in a goal column, and dropping D would take the column 4 cells that A and B need. So both have to go left into the space X leaves behind. The full chain reads: X waits for A and B, and A waits for C and D.

Step 3: count the free cells. There are five empty cells, two on row 3 and three on row 4. That is enough for A and B to step aside together.

Step 4: move the small pieces first, and far. Slide A right 2. Then slide B right 3, all the way to the corner. If B stopped after 2 cells it would sit in column 3, right inside the goal area.

Step 5: think in positions. Picture the position just before the last move: X in the bottom left, with column 3 empty on rows 3 and 4. To reach it, drop X down 2. Slide C left 2 and D left 2 into the top left corner. Now A can rise 1 into row 2, and the goal cells are clear. X slides right 1 and stands over the exit.

MovePieceDirectionCells
1Aright2
2Bright3
3Xdown2
4Cleft2
5Dleft2
6Aup1
7Xright1

This is where the tray ends up after move 7, with X over the exit:

Col 1Col 2Col 3Col 4
Row 1CD··
Row 2CDAA
Row 3·XX·
Row 4·XXB

Other shortest lines exist: a computer search counts 4 different 7-move solutions for this tray.

Notice that B, the smallest piece, moved only once and made the longest single slide. No move was ever undone, which is a good sign that a solution is short.

How does a parking block puzzle work?

A parking block puzzle is a grid of bars, each lying either across or upright. A bar that lies across slides only left and right, and an upright bar slides only up and down. One bar, marked X, lies across a row with an exit at the right end of that row. You free X by clearing every bar out of its path.

Each bar has only two directions, so the blocker chain is quicker to trace. For each blocker you ask one question: can it leave the row by going up or by going down, and what stops it?

Here is an original 5 by 5 grid. X lies on row 3, and the exit is at the right end of row 3. A, C, D and E stand upright. B and F lie across, and F is three cells long.

Col 1Col 2Col 3Col 4Col 5
Row 1A·BBC
Row 2A·DEC
Row 3XXDE·
Row 4··FFF
Row 5·····

A computer search through every reachable arrangement confirms that 6 moves is the fewest possible.

The chain. X needs columns 3, 4 and 5 of row 3 to be empty. D and E stand in the way. E can only drop if F leaves column 4, and D could only drop if F also left column 3. F is three cells long, so even sliding as far left as it goes, it still covers column 3. That settles it: E goes down, and D must go up.

E could also rise, if B first slid left. But then B would sit over column 3, and D could go neither up nor down. That route is a dead end.

The second link. D can rise only when B leaves row 1, column 3. B can move right only when C leaves the top right corner. C cannot go up, and it must not stop on row 3, so it has to drop all the way to the bottom. That needs F out of column 5 first.

So F is the root of the whole chain, even though it never touches row 3. With F taken out of the grid, the computer search shows X could leave in just 3 moves.

MovePieceDirectionCells
1Fleft2
2Edown2
3Cdown3
4Bright1
5Dup1
6Xright3

A never moves at all. Not every piece in a puzzle is part of the chain, and moving pieces outside it is an easy way to waste moves.

How do computers find the shortest solution?

Every puzzle in this guide was checked by breadth-first search. The program lists every arrangement one move from the start, then every arrangement two moves away, and so on. The first time the goal shows up, that distance is the minimum. Our worked tray has 2,256 reachable arrangements and our practice tray 11,152, so the search finishes in moments.

Bigger puzzles need a smarter search that is guided by an estimate of how far each position is from the goal. A paper published on 21 August 2022 compared two such searches, A* and greedy best-first search, on a 4 by 4 numbered tile puzzle, and on the puzzle tested greedy best-first search took 22 iterations while A* took 35 [2].

People can borrow a habit from the greedy method analysed in the paper published on 10 July 2015: put the first row of the numbered puzzle in place, then the first column, then solve the smaller square that remains in the same way [1].

In a block tray the same habit helps. Settle one part of the tray, then treat the rest as a smaller puzzle.

What mistakes cost the most moves?

MistakeWhat goes wrongBetter habit
Moving the target before tracing the chainIt parks in a spot that blocks the pieces that need to passMove the target early only when that opens space the chain needs
Sliding a piece only part wayIt stops inside the goal cellsSlide small pieces to the far end of their line
Splitting the empty cellsThe 2x2 target needs a pair of empty cells, not two loose onesKeep empty cells side by side
Undoing the last moveTwo moves vanish with nothing gainedLook for a different chain
Moving pieces outside the chainExtra moves, and sometimes new blockersMove only what the chain names

Can you solve this practice tray?

Here is a second original tray. The rules are the same: X is the 2x2 target, the exit is under columns 2 and 3 of the bottom wall, and X must finish on rows 3 and 4 of those columns. A is a flat bar, B and C are standing bars, and D and E are single squares.

Col 1Col 2Col 3Col 4
Row 1·XX·
Row 2·XX·
Row 3AABC
Row 4DEBC

A computer search confirms that 11 moves is the fewest possible. Hint: X has to step sideways before it can drop, and the pieces below it have to swap places with the empty cells above.

What is the answer to the practice tray?

Start by sliding X right 1. Moving the target first looks like a rule break, but here it is the only move that opens space: the pieces below X need the empty cells on the left, and only X can let them in.

That step opens the left two columns of rows 1 and 2. A rises 2 to the top row, and D and E each rise 2 into row 2. Now the bottom two rows hold only B and C, and both can slide left 2. The right half of rows 3 and 4 is empty, so X drops 2.

X now sits one column right of the goal. To shift it left, column 2 must be clear on rows 3 and 4, and C is there. C can only go up, so its column must be cleared first: A slides right 2 and E slides right 1. C rises 2, and X slides left 1 over the exit.

MovePieceDirectionCells
1Xright1
2Aup2
3Dup2
4Eup2
5Bleft2
6Cleft2
7Xdown2
8Aright2
9Eright1
10Cup2
11Xleft1

The finished tray looks like this:

Col 1Col 2Col 3Col 4
Row 1·CAA
Row 2DCE·
Row 3BXX·
Row 4BXX·

This is not the only shortest line: a computer search counts 8 different 11-move solutions, and every one of them begins with X right 1.

If you needed more than 11 moves, look for a step you later undid, or a piece you moved that was never in the chain.

Where can you try this kind of thinking next?

Working backwards from the goal and counting the fewest steps is the heart of this Riddle10 puzzle about a shortest route. Try it, and look for the moment where thinking from the end saves you the most work.

References

  1. Parberry, I. (2015, July 10). Solving the (n² − 1)-Puzzle with 8/3 n³ Expected Moves. Algorithms, 8(3), 459-465. DOI 10.3390/a8030459
  2. Setyobudhi, C. T. (2022, August 21). Comparison of A* Algorithm and Greedy Best Search in Searching Fifteen Puzzle Solution. International Journal of Computer and Information Technology, 11(3). DOI 10.24203/ijcit.v11i3.242

sliding block puzzles block puzzles parking block puzzles movement puzzles mechanical puzzles step by step solving methods

More reading