From f3a475d4744c4c2b631c24f4875b5c845baa1f93 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Fri, 12 Jan 2024 09:11:07 +0200 Subject: Fixing bug where 1x1 wont uncover. --- board/board.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'board/board.py') diff --git a/board/board.py b/board/board.py index 3b5cd77..9666bad 100644 --- a/board/board.py +++ b/board/board.py @@ -60,6 +60,8 @@ class Board(): def collect_area(self, x, y, area=set()): + if not area: + area.add((x,y)) to_test = [] for dx, dy in ( (0,-1), (-1,0), (1,0), (0,1) ): if self.invalid_coordinates(x+dx, y+dy): @@ -68,7 +70,6 @@ class Board(): to_test.append((x+dx, y+dy)) area.add((x+dx, y+dy)) for tx, ty in to_test: - area.add((x,y)) area=area.union(self.collect_area(tx, ty, area)) return area -- cgit v1.2.3