aboutsummaryrefslogtreecommitdiff
path: root/2021/04/puzzles.py
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-12 06:56:03 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-12 06:56:03 +0100
commitb4195baae3b36bd997a97d24fd5e0ab38dcd5595 (patch)
treeeca4ea75f16be761da19409b83a45ce88dd1b0c5 /2021/04/puzzles.py
parentc93fc1b9a11c96a4554ec47029bf085597fdef60 (diff)
Add libaoc
Diffstat (limited to '2021/04/puzzles.py')
-rw-r--r--2021/04/puzzles.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/2021/04/puzzles.py b/2021/04/puzzles.py
index 20036e0..46dfa05 100644
--- a/2021/04/puzzles.py
+++ b/2021/04/puzzles.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
-board = list[list[int]]
+from libaoc import flatten, map2d, matrix
+
+board = matrix[int]
last: board = []
@@ -42,8 +44,7 @@ def main() -> None:
# START PART 2
boards = list(filter(lambda b: not bingo(b), boards))
# END PART 2
-
- print(num * sum(map(lambda x: sum(filter(lambda n: n != -1, x)), last)))
+ print(num * sum(flatten(map2d(lambda n: 0 if n == -1 else n, last))))
if __name__ == "__main__":