From 53524191026c46cf96e8f6d13859a25d65039698 Mon Sep 17 00:00:00 2001 From: Garmelon Date: Fri, 12 Feb 2016 20:20:26 +0100 Subject: [PATCH] Implement in_boundaries, get_cell, set_cell, replace functions --- maze.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/maze.py b/maze.py index 33cfbc4..43b98be 100644 --- a/maze.py +++ b/maze.py @@ -49,7 +49,7 @@ class 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): """ @@ -57,7 +57,7 @@ class Maze: Return the value of the cell at x, y. """ - pass + return self.maze[y][x] def set_cell(self, x, y, val): """ @@ -65,7 +65,7 @@ class Maze: Set the value of the cell at x, y to val. """ - pass + self.maze[y][x] = val def replace(self, val1, val2): """ @@ -73,7 +73,10 @@ class Maze: 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): """