The Gatehouse

Maze solver.

Which wall would you open? Draw a maze, trace the shortest route, then change one square and see what it saves.

The Courtyard11 × 7
The interactive board requires JavaScript. The worked example below explains the shortest path.
S StartE ExitK Optional key
Paste or copy a text maze

Use # for a wall, . or a space for a floor, S for your start and E for your exit. A single K locks the exit until you collect the key. Each row must have the same width, up to 41 × 41.

The one-wall challenge for two players

Open The Courtyard. The shortest route starts at 12 steps. Without moving S or E, predict one interior wall you could open to get down to eight. Choose Floor and test your prediction. Use Undo to let a partner try.

Show the eight-step solution

Open the wall in row 2, column 5, counting from the top left. The new route goes straight from S to E. They are eight columns apart, so even a completely open board cannot beat eight steps.

How does a maze solver find the shortest path?

It checks every square one step from the start, then those two steps away, and so on. When a layer reaches the exit, its distance gives the fewest possible moves. This is called breadth-first search.

Consider this open square. You can go right twice and down twice in six different orders. All six routes reach the exit in four steps.

S..
...
..E

With a key, visiting the same square before and after picking it up counts as two different situations. A valid route may double back.

MazeFang game showing a keeper beside a swing gate

Make the gate move.

MazeFang turns the walls into part of the puzzle. Swing a gate, nudge the sleeping Fang into its pen and get the keeper out. The first 32 rooms are free.

Get MazeFang for iPhone or iPad ↗Try a swing gate here