Question: We can represent a maze on a rectangular grid as a list of paths. Each path consists of a pair of coordinates which are the
We can represent a maze on a rectangular grid as a list of paths. Each path consists of a pair of coordinates which are the ends of the path, where a coordinate is a pair of nonnegative integers x y All paths run either horizontally same yvalue for both ends or vertically same xvalue for both ends A path of length is considered to be both horizontal and vertical. The order of the ends of a paths is not important; the path is equivalent to the path Similarly, the order of the paths in the maze is unimportant.
Write a function:
renderMaze :: Int IntInt IntString
that renders the maze rowbyrow as a list of strings. Each character in each string represents a coordinate within the maze. If a horizontal path is present at that coordinate, the character should be a hyphen symbol If a vertical path is present at that coordinate, the character should be a bar symbol If that coordinate lies on both a horizontal and vertical path, the character should be a plus symbol If a path is not present, the character should be a space.
For example, if we have defined:
maze
then renderMaze maze should return: Written an way that is easier to read, this is
The grid in the rendering should run from in the top left corner to maxXmaxY in the bottom right, where maxX and maxY are the largest x and y values to appear in any path in the maze.
Hint: you may find it useful to use list comprehensions to calculate all of the xy points that appear in a maze.
For example:
TestResult
renderMaze
renderMaze Singleton Path
renderMaze Singleton Path, maze size x
renderMaze Horizontal Path
renderMaze Horizontal Path, switched endpoints
renderMaze Vertical Path
renderMaze Vertical Path, switched endpoints
renderMaze Intersecting Paths
renderMaze Overlapping Paths
renderMaze NonIntersecting Paths
renderMaze personlike shape
renderMaze lambda shape
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
