diff --git a/puzzles/1.py b/puzzles/1.py index 7cecb4b..2887847 100644 --- a/puzzles/1.py +++ b/puzzles/1.py @@ -7,7 +7,7 @@ test_input = """ 1 3 3 9 3 3 -""".strip() +""" test_solution_p1 = 11 test_solution_p2 = 31 @@ -28,6 +28,6 @@ def solve_p2(puzzle_input: str) -> int: def _parse_lists(puzzle_input: str) -> tuple[list[int], list[int]]: - lines = (line.partition(" ") for line in puzzle_input.split("\n") if line) + lines = (line.partition(" ") for line in puzzle_input.strip().split("\n")) list1, list2 = zip(*((int(line[0]), int(line[2])) for line in lines)) return list1, list2 diff --git a/puzzles/2.py b/puzzles/2.py index cc208b7..3e8ba4a 100644 --- a/puzzles/2.py +++ b/puzzles/2.py @@ -10,7 +10,7 @@ test_input = """ 1 3 2 4 5 8 6 4 4 1 1 3 6 7 9 -""".strip() +""" test_solution_p1 = 2 test_solution_p2 = 4 @@ -41,7 +41,7 @@ def solve_p2(puzzle_input: str) -> int: def _parse_reports(puzzle_input: str) -> Iterator[tuple[int, ...]]: - lines = puzzle_input.splitlines() + lines = puzzle_input.strip().splitlines() return (tuple(int(level) for level in line.split(" ")) for line in lines) diff --git a/puzzles/3.py b/puzzles/3.py index 1226c69..d3befd8 100644 --- a/puzzles/3.py +++ b/puzzles/3.py @@ -1,12 +1,13 @@ import re from functools import reduce -test_input_p1 = ( - "xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))" -) -test_input_p2 = ( - "xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))" -) +test_input_p1 = """ +xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) +""" + +test_input_p2 = """ +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) +""" test_solution_p1 = 161 test_solution_p2 = 48 diff --git a/puzzles/4.py b/puzzles/4.py index 97baf6d..0291751 100644 --- a/puzzles/4.py +++ b/puzzles/4.py @@ -11,7 +11,7 @@ SMSMSASXSS SAXAMASAAA MAMMMXMMMM MXMXAXMASX -""".strip() +""" test_solution_p1 = 18 test_solution_p2 = 9 @@ -29,7 +29,7 @@ def solve_p2(puzzle_input: str) -> int: def _parse_world_grid(puzzle_input: str) -> tuple[tuple[str, ...], ...]: - return tuple(tuple(row) for row in puzzle_input.splitlines()) + return tuple(tuple(row) for row in puzzle_input.strip().splitlines()) def _scan_word_grid( diff --git a/puzzles/5.py b/puzzles/5.py index 57be724..34d2e65 100644 --- a/puzzles/5.py +++ b/puzzles/5.py @@ -29,7 +29,7 @@ test_input = """ 75,97,47,61,53 61,13,29 97,13,75,29,47 -""".strip() +""" test_solution_p1 = 143 test_solution_p2 = 123 diff --git a/puzzles/6.py b/puzzles/6.py index 8775a06..4c71977 100644 --- a/puzzles/6.py +++ b/puzzles/6.py @@ -11,7 +11,7 @@ test_input = """ ........#. #......... ......#... -""".strip() +""" test_solution_p1 = 41 test_solution_p2 = 6 @@ -51,7 +51,7 @@ def _parse_map(puzzle_input: str) -> MapInfo: puzzle_map = [] guard = None - for x, line in enumerate(puzzle_input.split("\n")): + for x, line in enumerate(puzzle_input.strip().split("\n")): if not line: continue line_list = list() diff --git a/puzzles/7.py b/puzzles/7.py index be98f11..6406e8f 100644 --- a/puzzles/7.py +++ b/puzzles/7.py @@ -13,7 +13,7 @@ test_input = """ 192: 17 8 14 21037: 9 7 18 13 292: 11 6 16 20 -""".strip() +""" test_solution_p1 = 3749 test_solution_p2 = 11387 @@ -50,7 +50,7 @@ class Equation(NamedTuple): def _parse_equations(puzzle_input: str) -> Iterator[Equation]: - for line in puzzle_input.split("\n"): + for line in puzzle_input.strip().split("\n"): if line: result_string, _, factors_string = line.partition(": ") yield Equation( diff --git a/puzzles/8.py b/puzzles/8.py index 32dd629..2e3ea81 100644 --- a/puzzles/8.py +++ b/puzzles/8.py @@ -14,7 +14,7 @@ test_input = """ .........A.. ............ ............ -""".strip() +""" test_solution_p1 = 14 test_solution_p2 = 34