https://ucsb-cs9.github.io/s23/lab/lab04/
I honestly do not understand what to do with stacks
this is the core of my code:
Stack.py
class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items) - 1]
def size(self):
return len(self.items)
testFile.py
from lab04 import solveMaze
def printMaze(maze):
for row in range(len(maze)):
for col in range(len(maze[0])):
print("|{:<2}".format(maze[row][col]), sep='',end='')
print("|")
return
def test_example():
maze = [
['+','+','+','+','G','+'],
['+',' ','+',' ',' ','+'],
['+',' ',' ',' ','+','+'],
['+',' ','+','+',' ','+'],
['+',' ',' ',' ',' ','+'],
['+','+','+','+','+','+'] ]
assert solveMaze(maze, 4, 4) == True
assert maze == [
['+', '+', '+', '+', 'G', '+'],
['+', 8, '+', 11, 12, '+'],
['+', 7, 9, 10, '+', '+'],
['+', 6, '+', '+', 2, '+'],
['+', 5, 4, 3, 1, '+'],
['+', '+', '+', '+', '+', '+'] ]
test_example()