Your Turn

So, that’s Dijkstra’s algorithm. As mentioned, it’s not the only way—nor even the fastest way—to solve mazes, but it’s certainly a useful way. We’ve seen how to use it to find a path between two cells. We’ve also seen how it can be used to find a longer (and hopefully more challenging) path through a maze. Finally, we used Dijkstra to color mazes, allowing us to look inside and see their underlying structures.

There’s a lot of room to explore, here. Take some time to fiddle with Dijkstra’s algorithm. Get familiar with it. It’s going to be our faithful companion throughout this book!

If you need some ideas to get started, consider some of these.

Animate Dijkstra’s algorithm.

What if you were to draw the maze at each step of Dijkstra’s ...

Get Mazes for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.