Skip to content

How to Solve a Maze: The Wall-Follower Rule (and When It Fails)

How to solve a maze with the wall-follower rule: one hand on the wall, a drawn example, a maze to try, and what to do when the rule goes round in circles.

Wondering how to solve a maze when you have no idea which way to turn? There is one simple rule that gets you out of most of them: keep one hand on the wall and keep walking. This post shows how the wall-follower rule works on a small drawn maze, what to do when it fails, and a maze for you to try.

1. The wall-follower rule in one sentence

Put one hand on a wall and never let go. Walk on, keep your hand touching the wall, and you will come out at the exit. Pick your right hand or your left, and keep to it.

At every moment, the rule is:

  • If you can turn toward your hand, turn.
  • If you can’t, go straight on.
  • If you can’t go straight on, turn away from your hand.
  • At a dead end, turn all the way round and keep your hand on the wall.

Why it works: in a maze with no loops (no closed circle of corridors you could walk round), the walk can’t go round in a circle forever. It has to end at the exit. There is no guessing, and no need to remember where you have been.

The left hand does the same job in mirror image. This post uses the right hand.

2. How to solve a maze, step by step

The worked maze: coral walls, cream paths, an entrance on the left and an exit on the right.
The worked maze. The entrance is the gap in the left wall, the exit the gap in the right wall.

Start at the entrance on the left, with your right hand on the wall. Count one step each time you move from one room to the next. The walk goes like this:

  • Down the left corridor: 3 steps.
  • Along the lower corridor to the right: 2 steps.
  • Up the little stub: 1 step.
  • Across: 1 step.
  • Down the long corridor on the right: 2 steps.
  • West along the bottom row, into its dead end: 3 steps.
  • Back east along the bottom row: 4 steps.
  • Out through the exit.

The trip into the dead end is the rule at work: your hand leads you in, and then back out. The picture below shows the whole walk, with that detour in another colour.

The worked maze with the right-hand walk in green and the dead-end detour along the bottom row in blue.
The right-hand walk through the worked maze. The dead-end detour is in another colour.

That is 16 steps. The shortest way through this maze is 10 steps, and the left-hand walk takes 32. The rule always gets you out, though not always by the quickest way. Keep your hand light on the wall and go at an easy pace: there is nothing to rush.

3. Try it: a maze for you

The practice maze: coral walls, cream paths, an entrance on the left and an exit on the right.
The practice maze. The entrance is the gap in the left wall, the exit the gap in the right wall.

Put a finger, or a pencil, on the entrance and walk the right-hand rule to the exit. Then walk the left-hand rule the same way and compare how far each one goes. Count one step for each room you move into.

Show the answer

The one right path takes 18 steps. From the entrance room: right 2, down 2, left 1, up 1, left 1, down 3, right 2, up 1, right 1, down 1, right 2, down 1, then out through the exit gap. This maze has only one route from start to finish, so there is only one answer.

The practice maze with the one right path drawn in green from entrance to exit.
The one right path, from the entrance room to the exit.

The right-hand walk takes 28 steps. It follows the same path, but walks into the dead end of the bottom row and back before it reaches the exit.

4. When the wall-follower rule fails

The rule breaks when the wall you follow is an island: a block of wall that stands on its own and doesn’t join the outside wall. If you start beside such a block, your hand stays on it, and you walk round and round it without ever reaching the exit.

An empty room with a solid block of wall in the middle, a gold S beside it and a gap in the right wall.
The island room. With the left hand on the block, the walk goes round and back to the start, forever.

Here the walk starts at S, beside the block, with the left hand on it: down, along the bottom, up the right side, along the top, down the left side, and back to S. Then it goes round again.

Two signs you are looping: you pass the same spot twice, and a mark you left comes round again. A pencil dot is a good mark. When you see either sign, let go of the wall and try the next trick.

This cannot happen in a maze with no loops. In such a maze every block of wall joins the outside wall, as in the two mazes above.

5. The fix: pick a direction and count your turns

The Pledge trick, in plain words: pick a direction, say east, and walk that way until a wall stops you. Then put your hand on that wall and follow it, counting your turns: add 1 for each turn to the right, and take 1 away for each turn to the left.

When you are facing east again and the count is 0, let go of the wall and walk straight on. A count of 0 means you have not gone round the block, so you are free to leave the wall.

The island room with a green route from S down beside the block, then straight east to the exit.
The Pledge route. Blocked facing east, turn right, then turn left at the row below the block, and walk straight east to the exit.

On this room the walk takes 10 steps, the same as the shortest way. The block stops you at once, so turn right (count 1) and go down beside the block. At the row below the block, turn left (count 0, facing east). Let go, and walk straight east to the exit.

Keep it light: the counting is only adding and taking away one. A pencil mark on the paper keeps the count.

6. A quick trick: work backwards from the exit

On a paper maze, you can also start at the exit and trace back toward the entrance.

Cross out each dead end as you find it: any path that ends in a wall, and any path that leads only to crossed-out ones. What is left is the route.

Combine the two: use the wall-follower when you are inside the maze, and the backwards trace when you can see the whole maze on paper.

Put it into practice

Outside, in a garden or corn maze, try the hand on the wall first, and watch for loops. On paper, try the walk from both ends.

For more ways to think through a puzzle, read how to get better at logic puzzles, or try 10 brain teasers for a 5-minute break next.

How did your hand do?

Play a free game

←All posts