diff options
Diffstat (limited to '2021/04/puzzles.py')
-rw-r--r-- | 2021/04/puzzles.py | 7 |
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__": |