diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-04 07:07:34 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-04 07:07:34 +0100 |
commit | 7400db62502d6bf5bc330859973e22c4c602604c (patch) | |
tree | 3b2a52daea4a5383d0d6ec201947a58ec087edd9 | |
parent | 8f64cdb569e9542c3a56cc2315eba1d9e91ebd43 (diff) |
Remove some useless code, and minor cleanup
-rw-r--r-- | 2021/04/puzzles.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/2021/04/puzzles.py b/2021/04/puzzles.py index 581aef5..858450f 100644 --- a/2021/04/puzzles.py +++ b/2021/04/puzzles.py @@ -24,12 +24,11 @@ def bingo(board: board) -> bool: def main() -> None: boards: list[board] = [] with open("input", "r", encoding="utf-8") as f: + draws = list(map(int, f.readline().split(","))) lines = f.readlines() for i, line in enumerate(lines): - if i == 0: - draws = list(map(int, line.strip().split(","))) - elif line == "\n": - boards.append([list(map(int, lines[i + j].strip().split())) for j in range(1, 6)]) + if line == "\n": + boards.append([list(map(int, lines[i + j].split())) for j in range(1, 6)]) # START PART 1 while not any(bingo(b) for b in boards): @@ -37,9 +36,9 @@ def main() -> None: while len(draws) > 0 and len(boards) > 0: # END PART 2 num = draws.pop(0) - for i, board in enumerate(boards): - for j, row in enumerate(board): - boards[i][j] = [-1 if n == num else n for n in row] + for board in boards: + for i, row in enumerate(board): + board[i] = [-1 if n == num else n for n in row] # START PART 2 boards = list(filter(lambda b: not bingo(b), boards)) # END PART 2 |