r/programmingchallenges • • Sep 09 '11

Make a perfect maze.

A perfect maze is one that has one and only one path between any two points in it (without backtracking).

There are quite a few algorithms out there for this, but trying to make your own is good fun.

29 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/HigherFive Sep 10 '11

It looks like you're pretty much doing a depth first search. Is that it?

I like it though, surprisingly concise.

2

u/[deleted] Sep 10 '11

Yep, that's the one :) Didn't use a reference implementation, though. I was too surprised by how short it was (and how quickly it generated large mazes); somehow I expected maze generation was much more complex.