Question: lab 0 4 . py This file will contain a single function definition maze _ path _ exists ( maze , start _ x ,
labpy
This file will contain a single function definition mazepathexists maze startx starty The maze parameter will be the D List maze as described above.
startx and starty are the starting coordinates used when traversing the maze mazestartxstarty You may assume that startx and starty position is
a valid position ie it's contained within the maze and no or value exists in that position in the D List
The mazepathexists 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 well 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 mazepathexists 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 testexample:
maze
G
assert mazepathexistsmaze True
assert maze
G
:
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
