How to solve Klotski in 81 moves
The classic Klotski layout looks impossible at first. The shortest solution takes 81 moves, and it breaks down into five clear phases.
Play Klotski nowSlide Cao Cao out – 9 classic layoutsHow moves are counted
In Klotski, sliding one block counts as one move, however far it travels and even if it turns a corner. Counted this way, the famous starting position Blade Across (横刀立马) needs at least 81 moves. The diagrams below come from a shortest solution found by computer search: C = Cao Cao (2×2), G = Guan Yu (wide), Z, Y, M, H = the four tall generals, s = soldier, · = empty. The exit is at the bottom, under the middle two columns.
Start Z C C Y Z C C Y M G G H M s s H s · · s
Phase 1 (moves 1–21): get Guan Yu out of the way
Guan Yu sits right under Cao Cao and has to go first. Shuffle the soldiers and the lower generals until Guan Yu reaches the bottom row.
After move 21 Z C C Y Z C C Y s s M H · · M H G G s s
Phase 2 (moves 22–32): line up the generals
Cao Cao steps aside and comes back, and the four tall generals end up standing side by side in the middle of the board. The empty column at the top right is the key: it is room for Cao Cao to start moving down.
After move 32 s C C · s C C · M Z H Y M Z H Y G G s s
Phase 3 (moves 33–48): bring Cao Cao into the middle
By sliding generals up beside him, Cao Cao drops two rows into the centre of the board.
After move 48 s s s Y M · · Y M C C H Z C C H Z s G G
Phase 4 (moves 49–73): send the generals to the top
This is the long part. Cao Cao moves right, back to the middle and then left, while the four generals climb past him. By move 73, all four stand side by side in the top two rows and Cao Cao is on the left, one row from the bottom.
After move 73 Z M Y H Z M Y H C C s s C C G G s s · ·
Phase 5 (moves 74–81): the escape
Cao Cao drops into the bottom-left corner, Guan Yu moves up out of the way, the soldiers tidy up and Cao Cao slides right into the exit on move 81.
Solved (move 81) Z M Y H Z M Y H s s G G · C C s · C C s
Ideas that help in every layout
- Keep the two empty squares together. Two joined holes let a tall or wide block move. Two separate holes only let soldiers move.
- Think about where the space goes, not just where the blocks go. Every move moves the empty squares too.
- Don’t rush Cao Cao downwards. The shortest solution moves him sideways several times first.
Try it yourself in Klotski. Get stuck, and the Hint button shows the next move of a shortest solution from wherever you are.
Play Klotski nowSlide Cao Cao out – 9 classic layouts