Solving Mazes by Coloring

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Many Demonstrations show how to solve a maze with depth-first search or breadth-first search. Another kind of solution is based on coloring the different connected components of the set of walls. Every maze is divided into two components by the solution path, which is just the boundary between the two components. This is easy to see if you color the two components with different colors. Mazes with more than two connected components have more than one solution. This Demonstration lets you generate mazes of size up to 15×15 with up to six connected components and to color them to see the solution.


Large mazes are quite slow to generate in this implementation.


Contributed by: Jason Cantarella (May 2012)
(University of Georgia Math Department)
Open content licensed under CC BY-NC-SA



This Demonstration was developed for an elementary school math activity at the Waseca Montessori School in Athens, Georgia.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.