From b4195baae3b36bd997a97d24fd5e0ab38dcd5595 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 12 Dec 2021 06:56:03 +0100 Subject: Add libaoc --- 2021/04/puzzles.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to '2021/04') 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__": -- cgit v1.2.3