Klotski (Huarong Dao) Solver

Solve the classic Huarong Dao sliding-block puzzle — get the shortest move sequence and replay it step by step

How the puzzle works

The board is four squares wide and five tall. Cao Cao occupies a two-by-two block and must be moved to the opening at the bottom centre; the other pieces each occupy two squares, and the four soldiers one each. Blocks slide into empty space, one square at a time, and never lift or rotate. The solver searches the whole reachable state space breadth-first, so the sequence it returns is the shortest possible in single-square moves.

Tip: the number of moves differs from the number of block pushes — one push of a two-square piece counts as one move here. Watch the replay first, then try to reproduce it on a physical set.

More tools on this site