Since we've been having such a fine discussion on recursion, here's the challenge:

Generate a N x N maze using the following methodology for creation:
1 - Input a starting point, Y and X, where Y and X are in bounds for the maze.
2 - From the starting point, visit every other cell in the maze, you should use the following methods for moving:
-- If any neighboring squares are unvisited, pick one of them at random, and go there.
-- The act of moving there will remove the "wall" between the two cells. You may keep track of the "walls" however you like. The common method is to use a bit of masking, pardon the pun, to denote if a wall exists or not. A cell whose value is zero means it's unused. However, you can use any method to keep track of where you've been you choose.
-- If you reach a point where all neighboring cells are visited, you should begin backtracking your path to find a neighboring cell that isn't visited, and begin the process again.
-- When all rooms have been reached, you are to done.
3 - Implement the above method using recursion.
4 - Implement the above method without using recursion.
5 - You should have a method for printing your maze to the screen, or file, in the event it's too large. A maze might look like this:
Code:
+--+--+--+--+--+
|     |  |  |  |
+--+  +  +  +  +
|  |     |     |
+  +  +--+  +--+
|     |><|     |
+--+  +  +--+  +
|              |
+  +--+  +--+  +
|  |        |  |
+--+--+--+--+--+
It might, but you can make it however you like. That was just an example of a possible 5x5 maze. You could also denote the starting point, just as a point of interest. I did here with "><", because after all, X marks the spot.

If you're bored, also do the following:

1 - Given one of these generated mazes, enter a starting point and a finishing point.
2 - Implement a recursive method for finding the finishing point, using the above rules for generation. However in this case, you don't remove any walls, you simply go there. You'll need to keep track of your progress, so you can backtrack effectively.
3 - Implement an iterative version of the same pathing.


Quzah.