How to solve a maze
Rules, strategies, and algorithms — from your first maze to Einstein-level labyrinths.
What is a maze?
A maze is a network of passages separated by walls. There is one entrance (start) and one exit (end). Your job is to trace a path from start to end, navigating through open passages without crossing any walls.
Mazes have been around for thousands of years. The earliest known mazes appeared in Egyptian temples and Greek mythology — the Labyrinth of Crete being the most famous. Today, mazes are popular as puzzles in activity books, puzzle games, and brain-training apps.
On a grid-based maze like the ones here, every cell is connected to its neighbors by passages (no wall) or separated by walls. There are no diagonal moves. The solution is a sequence of cells from start to end where each consecutive pair shares an open passage.
Core rules
- Start at the marked cell. The start is labeled S (or a star icon in kids mode). The exit is labeled E (or a flag icon).
- Move through open passages. You can move up, down, left, or right — never diagonally. You cannot cross a wall.
- Backtrack when stuck. If you reach a dead end, retrace your steps to the last junction and try a different branch.
- Reach the exit to win. The puzzle is solved when your path connects the start cell to the end cell through a continuous sequence of open passages.
Controls
Desktop: Click adjacent cells to extend your path. Use arrow keys for fast navigation. Click any cell already on your path to retract to that point. Press Backspace to undo the last move. Ctrl+Z for multi-step undo, Ctrl+Y for redo.
Mobile: Tap adjacent cells to move. Tap a cell on your path to retract. Use the toolbar buttons for undo, redo, clear, and hints.
Keyboard shortcut: Press H to request a hint (up to 3 per puzzle in Classic and Timed Trial modes).
Strategy 1: Wall-following
The wall-following rule is the simplest maze-solving technique. Pick either the left wall or the right wall at the entrance and keep your hand on it. Follow the wall without lifting your hand until you reach the exit.
Why does it work? In a "perfect" maze — one where every cell is reachable and there are no loops — the walls form a single connected boundary. Following that boundary eventually traces the entire perimeter, which includes the exit.
When does it fail? If the maze has loops (disconnected islands of walls), the wall-following technique can trap you in an infinite loop around the island. The mazes on ThePuzzleLabs are perfect mazes, so wall-following always works here, but it may not give you the shortest path.
This technique is best for easy and medium mazes where the grid is small enough that the extra path length does not matter.
Strategy 2: Dead-end filling
Before you start tracing, scan the maze for dead ends. A dead end is a cell with only one open passage — you can enter it but must leave the same way. These cells can never be part of the solution path.
Mentally fill in (or cross out) each dead end. Then check the cells next to the filled dead end: if they now have only one open passage, they become new dead ends. Repeat until no more dead ends remain.
What remains is the "skeleton" of the maze — a much simpler network. The solution path is somewhere in this skeleton. On hard mazes where 35–45% of cells are dead ends, this technique eliminates a huge portion of the grid before you even start navigating.
Strategy 3: Tremaux's algorithm
For very large mazes (expert and Einstein levels), Tremaux's algorithm gives you a systematic exploration strategy:
- As you enter a passage, mark it (imagine drawing a line on the floor).
- At a dead end, turn around and walk back, marking the passage a second time.
- At a junction, prefer passages with no marks. If all passages have one mark, take any of them. Never enter a passage with two marks.
This guarantees you explore every reachable passage without going through any passage more than twice. When you reach the exit, you are done. The path from start to exit can be reconstructed by following passages with exactly one mark.
Strategy 4: Work from both ends
Look at the exit before you start. Trace a few steps backward from E in your mind. If the exit area has a narrow bottleneck — a single passage that the solution must pass through — knowing its location helps you aim your forward search toward it.
On larger mazes, identifying 2–3 bottlenecks divides the maze into independent sections. Solve the connection between bottlenecks first, then fill in each section. This "divide and conquer" approach is the key technique for expert-level puzzles.
Tips by difficulty
| Level | Grid | Best approach |
|---|---|---|
| Easy | 8–12 | Wall-following or trial and error. Quick to explore. |
| Medium | 14–18 | Dead-end filling first, then wall-following. |
| Hard | 20–25 | Dead-end filling + work from both ends. |
| Expert | 28–35 | Bottleneck identification + dead-end filling. |
| Einstein | 40–50 | Grid sectoring + Tremaux's algorithm. |
Play modes
- Classic: No time limit. Timer counts up. 3 hints available. Unlimited undo/redo. Best for learning and relaxed solving.
- Timed Trial: Countdown timer. Time limits range from 2 minutes (easy) to 20 minutes (Einstein). 3 hints. Unlimited undo.
- Challenge: No hints. No undo. No timer display. Tests pure navigation skill and spatial memory.