Question: lab 0 4 . py This file will contain a single function definition maze _ path _ exists ( maze , start _ x ,

lab04.py
This file will contain a single function definition maze_path_exists (maze, start_x, start_y). The maze parameter will be the 2D List maze as described above.
start_x and start_y are the starting coordinates used when traversing the maze (maze[start_x][start_y]). You may assume that start_x and start_y position is
a valid position (i.e., it's contained within the maze and no + or G value exists in that position in the 2D List).
The maze_path_exists function will utilize a Stack and update the maze elements with the number of steps at each traversed position. It should return True if a
path exists and the goal was reached, and return False if no path to the goal exists.
Stack.py
This file will simply contain a Stack class implementation exactly as the one covered in the book using Python Lists (we'll also cover this implementation in lecture
no need to write pytests for this, but Gradescope will check to see if this implementation is correct). This should contain a constructor (_, and the
isEmpty, push, pop, peek, and size methods. Your solution must utilize the Stack data structure and any of its methods to manage the traversal through the maze.
testFile.py pytest
This file will contain unit tests using pytest to test if your maze_path_exists functionality is correct. Think of various mazes (with or without solutions and different
sizes) and check to see if the traversal is correct according to these instructions. Write your tests first in order to check the correctness of your function. Again,
Gradescope requires
testFile.py to be submitted before running any autograded tests. You should write at least one test where a solution exists (different than
the one provided in these instructions), and another test where a solution does not exist. Remember that testing can help you debug your algorithm and ensure
your functionality works as expected.
An example of how we could write a pytest using the maze above using pytest: first, check the return value of the function, then verify that the maze after the
function execution looks as expected. Solving the path through the maze on paper can help write these test cases.
def test_example():
maze
'+','+','+','+','G',,'+],
','','+','','','+'],
['+','','','','+','+'],
','','+','+','','+'],
,'','','','','+'],
['+','+','+','+','+','+']]
assert maze_path_exists(maze,4,4)== True
assert maze
'+','+','+','+','G','+'],
?'+?',8,?'+?',11,12,?'+?',
?'+?',7,9,10,?'+?',?'+?',
?'+?',6,?'+?',+?',2,+?',
?'+?',5,4,3,1,?'+?',
{:['+?',+?',?'+?',+?',?'+?',?'+?']]
 lab04.py This file will contain a single function definition maze_path_exists (maze,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!