Question: Write and test the following function that uses a Stack: def stack _ maze ( maze ) : Solves a maze using
Write and test the following function that uses a Stack:
def stackmazemaze:
Solves a maze using DepthFirst search.
Use: path stackmaze maze
Parameters:
maze dictionary of points in a maze, where each point
represents a corridor end or a branch. Dictionary
keys are the name of the point followed by a list of
branches, if any. First point is named 'start', exit
is named dict
Returns:
path list of points visited before the exit is reached,
None if there is no exit list of str
Add the function to a PyDev module named functions. py Test it from
tpy
See Stacks Solving a Maze
This maze can be represented by a Python dictionary:
maze Start: AA: BCB: C:DE
: : :::
Each entry in these Python dictionaries consists of two parts:
ker: value
so for the sample maze, it's 'Start' entry has key: 'Start' and value: A
Since dictionaries use a key rather than an index, to extract a value from a dictionary use the syntax:
value maze key
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
