Implement in_boundaries, get_cell, set_cell, replace functions
This commit is contained in:
parent
e93581bb12
commit
5352419102
1 changed files with 7 additions and 4 deletions
11
maze.py
11
maze.py
|
|
@ -49,7 +49,7 @@ class Maze:
|
||||||
|
|
||||||
Return whether the coordinates lie within the boundaries of the maze.
|
Return whether the coordinates lie within the boundaries of the maze.
|
||||||
"""
|
"""
|
||||||
pass
|
return x >= 0 and y >= 0 and x < self.x and y < self.y
|
||||||
|
|
||||||
def get_cell(self, x, y):
|
def get_cell(self, x, y):
|
||||||
"""
|
"""
|
||||||
|
|
@ -57,7 +57,7 @@ class Maze:
|
||||||
|
|
||||||
Return the value of the cell at x, y.
|
Return the value of the cell at x, y.
|
||||||
"""
|
"""
|
||||||
pass
|
return self.maze[y][x]
|
||||||
|
|
||||||
def set_cell(self, x, y, val):
|
def set_cell(self, x, y, val):
|
||||||
"""
|
"""
|
||||||
|
|
@ -65,7 +65,7 @@ class Maze:
|
||||||
|
|
||||||
Set the value of the cell at x, y to val.
|
Set the value of the cell at x, y to val.
|
||||||
"""
|
"""
|
||||||
pass
|
self.maze[y][x] = val
|
||||||
|
|
||||||
def replace(self, val1, val2):
|
def replace(self, val1, val2):
|
||||||
"""
|
"""
|
||||||
|
|
@ -73,7 +73,10 @@ class Maze:
|
||||||
|
|
||||||
Replace all occurrences of val1 with another val2.
|
Replace all occurrences of val1 with another val2.
|
||||||
"""
|
"""
|
||||||
pass
|
for y in range(self.y):
|
||||||
|
for x in range(self.x):
|
||||||
|
if self.maze[y][x] == val1:
|
||||||
|
self.maze[y][x] = val2
|
||||||
|
|
||||||
def replace_integers(self, val):
|
def replace_integers(self, val):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue