From 7400db62502d6bf5bc330859973e22c4c602604c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 4 Dec 2021 07:07:34 +0100 Subject: Remove some useless code, and minor cleanup --- 2021/04/puzzles.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to '2021/04') 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 -- cgit v1.2.3