Remix Library / Techy

Maze Maker & Solver

Generate a random maze with depth-first search, then solve it with breadth-first search.

Advanced Python
No account needed: you’ll start as a guest.
read-only · remix to edit
Output

What you'll learn

  • Depth-first search
  • Breadth-first search
  • Stacks & queues
  • 2D grids
  • Sets & dictionaries

Challenges

Remix it, then try these. Each one is a bit harder than the last.

  1. Make a bigger maze by changing WIDTH and HEIGHT.
  2. Set SEED to a number so you get the same maze every time.
  3. Count how many dead ends the maze has.
  4. Solve it with depth-first search instead, and compare how many cells each one explores.
  5. Let the player walk through the maze by typing n/s/e/w.