Thinking in Code
Math · Foundational · Lesson 6 of 9

Escaping Mazes

The wall-follower rule

An interactive lesson with 7 steps, about 6 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.

What you’ll learn

  • The left-hand rule: turn left and step if you can, else forward, else turn right.
  • It always escapes a maze whose walls all connect to the outside.
  • Which hand is faster depends on the maze.

Steps

  1. A hand on the wall
  2. The spinning robot
  3. An island in the middle
  4. Why did it fail?
  5. Low battery
  6. Every square, twice at most
  7. The cost of dead ends