- Feb 3, 2005
- 7,326
- 2
- 76
My partner and I are having a hard time figuring out how to do this problem. Here's the description of the assignment:
Consider a two-dimensional array rolled into a cylinder so that the top and bottom rows are glued together.
A path is to be threaded from the left side of a cylinder to the right side, subject to the restrictions that from a given square you can move directly to the right, up and to the right, or down and to the right.
Some of the entries in the maze contain walls that are impassable. A wall is represented by the # character, and an open cell is represented by the . character.
Write a program, MazeSolver, that explores a cylindrical maze to find, and print, all left to right paths. If no paths exist, then print a message to that effect. The maze to explore is specified by three command line arguments.
A path is represented in a maze with the character - for moving due east, / for moving northeast, and \ for moving southeast.
Here's the method/procedure we have to create to solve this:
static int solve(char[][] maze, boolean printFlag) :
-Explores all left-to-right paths in the given maze and returns the number of solutions; each solution is printed iff the given printFlag is true.
We understand that there's a good chance we'll need a number of helper procedures to get this working. However, we're totally stuck on where to start. I think the main problem is the algorithm we'll need and the recursion/looping involved with all of this...and the fact that we need to find out ALL the solutions there are and print them makes it even more difficult and confusing. Where should we start? What should we do?
Any help, hints, tips, tidbits of code, etc...anything, really, is appreciated.
Consider a two-dimensional array rolled into a cylinder so that the top and bottom rows are glued together.
A path is to be threaded from the left side of a cylinder to the right side, subject to the restrictions that from a given square you can move directly to the right, up and to the right, or down and to the right.
Some of the entries in the maze contain walls that are impassable. A wall is represented by the # character, and an open cell is represented by the . character.
Write a program, MazeSolver, that explores a cylindrical maze to find, and print, all left to right paths. If no paths exist, then print a message to that effect. The maze to explore is specified by three command line arguments.
A path is represented in a maze with the character - for moving due east, / for moving northeast, and \ for moving southeast.
Here's the method/procedure we have to create to solve this:
static int solve(char[][] maze, boolean printFlag) :
-Explores all left-to-right paths in the given maze and returns the number of solutions; each solution is printed iff the given printFlag is true.
We understand that there's a good chance we'll need a number of helper procedures to get this working. However, we're totally stuck on where to start. I think the main problem is the algorithm we'll need and the recursion/looping involved with all of this...and the fact that we need to find out ALL the solutions there are and print them makes it even more difficult and confusing. Where should we start? What should we do?
Any help, hints, tips, tidbits of code, etc...anything, really, is appreciated.
