summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-12-04 14:54:10 +0000
committerTomasz Kramkowski <tk@the-tk.com>2021-12-04 14:54:10 +0000
commitf57a4810e22d446970c19286f8ebae4c9afa24ba (patch)
treeface4bdc27b04f01587920daad50581a30f55c7e
parentdd9578b2c39127674a17a9e13fbf1a728969e789 (diff)
downloadaoc2021-f57a4810e22d446970c19286f8ebae4c9afa24ba.tar.gz
aoc2021-f57a4810e22d446970c19286f8ebae4c9afa24ba.tar.xz
aoc2021-f57a4810e22d446970c19286f8ebae4c9afa24ba.zip
day 4: get rid of won set
-rw-r--r--4.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/4.py b/4.py
index 5e60e52..ed2f13c 100644
--- a/4.py
+++ b/4.py
@@ -34,17 +34,15 @@ class Board:
return Board([[int(n) for n in l.split()] for l in s.split('\n')])
def solve(nums: list[int], boards: list[Board]) -> tuple[int, int]:
- won: set[int] = set()
wins: list[int] = []
num: int
for num in nums:
i: int
board: Board
for i, board in enumerate(boards):
- if i in won: continue
+ if board.has_bingo: continue
board.call(num)
if board.has_bingo:
- won.add(i)
wins.append(num * board.unmarked_sum)
return wins[0], wins[-1]