Question: Figure below shows an example maze. In the maze, black cells are walls, which are obstacles that you can t move through. You can move
Figure below shows an example maze. In the maze, black cells are walls, which are obstacles that you
cant move through. You can move on the white cells and you cannot move beyond the boundaries of
the maze. In each maze, the starting location will be the square of Additionally, there is also one
white cell labeled with F This label shows the exit square of the maze. So you must extract the path
from S to F You can move in directions; up down, left, right. These directions will be represented by
characters U D L and R respectively.
The solution for the maze shown above is D D R R R R D D which means move down times, then
move right times and move down times. The maze a simple one way road and it has only one
solution: there is always one possible next square for each move.In Scheme, a maze will be represented in the form of a linkedlist. Figure below shows how the maze in
the first page is represented in terms of a linked list in Scheme. Starting cell has the letter S the
finishing cell has the letter F and empty cells have the letter E The walls have the letter minus
The following function "buildMaze" on the left is given for you which takes a list of lists and creates
a maze using the lists. You can use this function to create different mazes in order to test your code.
On the right the code shows how the maze in the Figure above is created.
define buildMaze rows
cond
null rows null
else cons buildMaze cdr rows
car rows
define sampleMaze buildMaze
S
E
EEEEE
E
F
Task : Define two functions "getHeight" and "getWidth" which takes a maze as an input and
returns the height and the width of the maze.
getHeight sampleMaze should return
getWidth sampleMaze should return
Task : Define a function "getLetter" which takes a maze, a row number and a column number.
Then it returns the letter from the maze on the corresponding location row column
getLetter sampleMaze should return S
getLetter sampleMaze should return E
getLetter sampleMaze should return
getLetter sampleMaze should return F
Task : Define a function "solveMaze" which takes a maze and returns the solution for the maze.
solveMaze sampleMaze should return D D R R R R D D
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
