From: Ruby Quiz Date: 2005-05-06T22:53:49+09:00 Subject: [QUIZ] Amazing Mazes (#31) The three rules of Ruby Quiz: 1. Please do not post any solutions or spoiler discussion for this quiz until 48 hours have passed from the time on this message. 2. Support Ruby Quiz by submitting ideas as often as you can: http://www.rubyquiz.com/ 3. Enjoy! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= by Matt Linnell We've had crosswords, cryptograms, chess puzzles, madlibs ... so why don't we try our hand at mazes? We can define the two basic components of this problem as: - Generating the maze - Solving the maze * Generating the maze * The maze is to be rectangular in shape, with the height and width determined at run time. All nodes of the maze must be reachable from any point. In other words, if one were to randomly pick a start/stop, the maze is always solvable. Furthermore, let us enforce that only 1 viable solution for the maze exists for any given start/stop (you cannot reach the same destination from 2 different routes). Generate an ASCII output representing the maze. * Solving the Maze * Given a maze produced from your above code, find the solution. Produce ASCII output to demonstrate/visualize solution. * Bonus Points * 1) Calculate which pair of start/stop points in the maze which gives you the longest possible path. 2) Calculate which pair of start/stop points in the maze which gives the most complicated path (involves the most turns) Example command line execution: $> ruby maze.rb {height} {width} [ {start} {stop} ]