StringMash.com

Printable maze generator

Square or circular mazes, from a five-by-five grid for a three-year-old to forty by forty. The answers print on their own pages.

On the sheet

Mazes

Name:

Find a way from Start to Finish without crossing a line.

StartFinish
Made at stringmash.com/maze-generator · 12 × 12 · sheet 1 · page 1 of 2

Mazes: answers

StartFinish
Made at stringmash.com/maze-generator · 12 × 12 · sheet 1 · page 2 of 2

Making a sheet

Pick a shape and a size. The sizes by age are a starting point: a five-by-five grid has big corridors for crayons, and twelve by twelve suits most seven- and eight-year-olds. Custom takes any grid from 3 to 60 cells a side, or 2 to 30 rings.

Square mazes start at the top left and finish at the bottom right. Circular ones start at a gap in the outer wall and finish at the dot in the middle. Put two or four mazes on a page for a quick activity, or one for a big, detailed maze.

The sheet number picks the mazes. Type the same number and you'll get the same sheet again, so a class can share a number and a teacher can print the answers later. New mazes jumps to a random number. Tick Answer pages and every maze gets a copy with its route drawn in red, on pages after the puzzles so they're easy to keep back.

Two ways to carve a maze

Each maze starts as a grid with every wall up. A maze with one route between any two points and no loops is called a perfect maze, and in graph terms it's a spanning tree of the grid: every cell joined, with no way to walk in a circle. Both styles here make perfect mazes. They just knock the walls down in a different order. Knocking through a wall joins two cells, so a 12 by 12 maze always has 143 openings inside it: one fewer than its 144 cells.

The circular mazes are the same idea on a different grid. The first ring round the centre has 6 cells, and a ring doubles its cells once they'd get more than twice as long as they are deep, so a 7-ring maze has 127 cells and a 10-ring one has 271. The carving code doesn't know which shape it's working on; it only sees which cells are next to which.

Long paths uses the recursive backtracker, a randomised depth-first search. It wanders off in a random direction, knocking through walls until it hits a dead end, then backs up to the last cell with an unvisited neighbour and sets off again. That gives long corridors that seldom branch, so the hard part is following a path that goes most of the way across the page before it gives up.

Short dead ends uses randomised Prim's algorithm. It grows the maze outwards from the start, each time joining a random cell on the edge of the maze so far. The result branches all the time, with many short dead ends. The route is often more direct, but there are more choices to make on the way.

The hand-on-the-wall rule

Put one hand on a wall at the entrance and keep it there. In a maze with no loops you'll always get out, because the walls are all joined to each other and you're tracing round all of them. It isn't quick, since you'll walk into every dead end on that side, but you can't get lost.

It fails in mazes with loops, where a wall can be an island you circle for ever. Every maze on this page is perfect, so the rule works on all of them, circular ones included.

Questions

Which size should I pick for my child?

Start with the size for their age and go up or down after the first one. Children who are just learning to hold a pencil do better with the 5 by 5 grid, as the corridors are wide. Short dead ends is often easier for young children than long paths, as the route is more direct.

Is there only one way through?

Yes. Every maze here is a perfect maze, with exactly one route between the start and the finish and no loops.

How do I get the same maze again?

Use the same sheet number and settings. The number seeds the maze generator, so the walls come out the same every time, on any device.

Can I print it without the answers?

Yes. Untick Answer pages. Or leave them on and print the page range you want, as the answers always come after the puzzles.

Can I use the mazes in a book I sell?

The mazes are made by your browser from a number, and we don't claim any rights in them. Use them for class, a party or a puzzle book.

Sources

Added . Last updated and reviewed . What's new