diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4ceaa5..a70385e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,11 +3,11 @@ ci: repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/pycqa/isort - rev: 7.0.0 + rev: 8.0.1 hooks: - id: isort name: isort @@ -40,6 +40,6 @@ repos: - id: matlab-reflow-comments args: [--line-length=100] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.10 + rev: v0.15.9 hooks: - id: ruff-check diff --git a/2015/Day_07/test_day7.py b/2015/Day_07/test_day7.py index cc7da0b..68acb19 100644 --- a/2015/Day_07/test_day7.py +++ b/2015/Day_07/test_day7.py @@ -4,8 +4,7 @@ from aoc_2015_day7 import CircuitDiagram PART_ONE = { - "input": dedent( - """\ + "input": dedent("""\ 123 -> x 456 -> y x AND y -> d @@ -14,8 +13,7 @@ y RSHIFT 2 -> g NOT x -> h NOT y -> i - """ - ), + """), "output": [ ("d", 72), ("e", 507), diff --git a/2015/Day_08/test_day8.py b/2015/Day_08/test_day8.py index 2ea83f1..a9e253a 100644 --- a/2015/Day_08/test_day8.py +++ b/2015/Day_08/test_day8.py @@ -14,14 +14,12 @@ class PuzzleTestCase(t.NamedTuple): escaped_len: int -puzzle_input = dedent( - r""" +puzzle_input = dedent(r""" "" "abc" "aaa\"aaa" "\x27" - """ -)[1:].splitlines() + """)[1:].splitlines() test_cases = [ PuzzleTestCase(puzzle_input[0], 2, 0, 6), PuzzleTestCase(puzzle_input[1], 5, 3, 9), diff --git a/2015/Day_14/test_day14.py b/2015/Day_14/test_day14.py index 0be2aca..3415bf4 100644 --- a/2015/Day_14/test_day14.py +++ b/2015/Day_14/test_day14.py @@ -4,12 +4,10 @@ import pytest from aoc_2015_day14 import Reindeer, ReindeerRace -PUZZLE_INPUT = dedent( - """\ +PUZZLE_INPUT = dedent("""\ Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. - """ -) + """) class RaceTestCase(t.NamedTuple): diff --git a/2015/Day_16/aoc_2015_day16.py b/2015/Day_16/aoc_2015_day16.py index 5351d32..6067227 100644 --- a/2015/Day_16/aoc_2015_day16.py +++ b/2015/Day_16/aoc_2015_day16.py @@ -3,8 +3,7 @@ from pathlib import Path from textwrap import dedent -GIFT_CLUE = dedent( - """\ +GIFT_CLUE = dedent("""\ children: 3 cats: 7 samoyeds: 2 @@ -15,8 +14,7 @@ trees: 3 cars: 2 perfumes: 1 - """ -).splitlines() + """).splitlines() def parse_gift_clue(clue_input: list[str]) -> dict[str, int]: diff --git a/2015/Day_18/test_day_18.py b/2015/Day_18/test_day_18.py index 1aece4d..fb5baa5 100644 --- a/2015/Day_18/test_day_18.py +++ b/2015/Day_18/test_day_18.py @@ -1,54 +1,44 @@ from textwrap import dedent SAMPLE_STEPS = [ - dedent( - """\ + dedent("""\ .#.#.# ...##. #....# ..#... #.#..# ####.. - """ - ), - dedent( - """\ + """), + dedent("""\ ..##.. ..##.# ...##. ...... #..... #.##.. - """ - ), - dedent( - """\ + """), + dedent("""\ ..###. ...... ..###. ...... .#.... .#.... - """ - ), - dedent( - """\ + """), + dedent("""\ ...#.. ...... ...#.. ..##.. ...... ...... - """ - ), - dedent( - """\ + """), + dedent("""\ ...... ...... ..##.. ..##.. ...... ...... - """ - ), + """), ] diff --git a/2015/Day_19/test_day_19.py b/2015/Day_19/test_day_19.py index 17b4084..b633e50 100644 --- a/2015/Day_19/test_day_19.py +++ b/2015/Day_19/test_day_19.py @@ -12,37 +12,31 @@ class ReactionTestCase(t.NamedTuple): REACTION_CASES = [ ReactionTestCase( - dedent( - """\ + dedent("""\ H => HO H => OH O => HH HOH - """ - ), + """), 4, ), ReactionTestCase( - dedent( - """\ + dedent("""\ H => HO H => OH O => HH HOHOHO - """ - ), + """), 7, ), ReactionTestCase( - dedent( - """\ + dedent("""\ H => OO H2O - """ - ), + """), 1, ), ] diff --git a/2016/Day_02/aoc_2016_day02.py b/2016/Day_02/aoc_2016_day02.py index 0fc8994..f7267bc 100644 --- a/2016/Day_02/aoc_2016_day02.py +++ b/2016/Day_02/aoc_2016_day02.py @@ -3,21 +3,17 @@ from helpers.geometry import COORD -KEYPAD = dedent( - """\ +KEYPAD = dedent("""\ 123 456 - 789""" -) + 789""") -DIAMOND_KEYPAD = dedent( - """\ +DIAMOND_KEYPAD = dedent("""\ 1 234 56789 ABC - D""" -) + D""") DELTA = { "U": (0, -1), @@ -63,7 +59,7 @@ def find_bathroom_code(instructions: str, keypad: dict[COORD, str], start_loc: C for digit_line in instructions.splitlines(): for move in digit_line: dx, dy = DELTA[move] - (nx, ny) = (x + dx, y + dy) + nx, ny = (x + dx, y + dy) if (nx, ny) in keypad: x, y = nx, ny diff --git a/2016/Day_02/test_day02.py b/2016/Day_02/test_day02.py index 200860b..32eaf3c 100644 --- a/2016/Day_02/test_day02.py +++ b/2016/Day_02/test_day02.py @@ -4,14 +4,12 @@ from .aoc_2016_day02 import DIAMOND_KEYPAD, KEYPAD, find_bathroom_code, parse_keypad -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ULL RRDDD LURDL UUUUD - """ -) + """) TEST_CASES = ( diff --git a/2016/Day_03/test_day03.py b/2016/Day_03/test_day03.py index 70ee7f3..4089ee2 100644 --- a/2016/Day_03/test_day03.py +++ b/2016/Day_03/test_day03.py @@ -7,16 +7,14 @@ def test_is_triangle() -> None: assert is_possible_triangle("5 10 25") is False -VERTICAL_SPEC = dedent( - """\ +VERTICAL_SPEC = dedent("""\ 101 301 501 102 302 502 103 303 503 201 401 601 202 402 602 203 403 603 - """ -) + """) TRUTH_TRIANGLES = ( "101 102 103", diff --git a/2016/Day_04/test_day04.py b/2016/Day_04/test_day04.py index f6d6e71..12120fc 100644 --- a/2016/Day_04/test_day04.py +++ b/2016/Day_04/test_day04.py @@ -29,14 +29,12 @@ def test_room_checksum( assert is_valid_room(components) is truth_is_room -SAMPLE_ROOM_SPEC = dedent( - """\ +SAMPLE_ROOM_SPEC = dedent("""\ aaaaa-bbb-z-y-x-123[abxyz] a-b-c-d-e-f-g-h-987[abcde] not-a-real-room-404[oarel] totally-real-room-200[decoy] - """ -) + """) def test_sector_sum() -> None: diff --git a/2016/Day_06/test_day06.py b/2016/Day_06/test_day06.py index 30a0f07..bb263f8 100644 --- a/2016/Day_06/test_day06.py +++ b/2016/Day_06/test_day06.py @@ -2,8 +2,7 @@ from .aoc_2016_day06 import correct_message -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ eedadn drvtee eandsr @@ -20,8 +19,7 @@ vrdear dvrsen enarar - """ -) + """) def test_error_correction() -> None: diff --git a/2016/Day_08/test_day08.py b/2016/Day_08/test_day08.py index 9f156c5..aacc96e 100644 --- a/2016/Day_08/test_day08.py +++ b/2016/Day_08/test_day08.py @@ -2,14 +2,12 @@ from .aoc_2016_day08 import Screen, calculate_lit_pixels, parse_instructions -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ rect 3x2 rotate column x=1 by 1 rotate row y=0 by 4 rotate column x=1 by 1 - """ -) + """) def test_n_lit() -> None: @@ -17,12 +15,10 @@ def test_n_lit() -> None: assert calculate_lit_pixels(instructions) == 6 -TRUTH_END_STATE = dedent( - """\ +TRUTH_END_STATE = dedent("""\ .#..#.# #.#.... - .#.....""" -) + .#.....""") def test_screen_state() -> None: diff --git a/2016/Day_10/test_day10.py b/2016/Day_10/test_day10.py index ef3ac5d..e2d5819 100644 --- a/2016/Day_10/test_day10.py +++ b/2016/Day_10/test_day10.py @@ -3,16 +3,14 @@ from .aoc_2022_day10 import Factory -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ value 5 goes to bot 2 bot 2 gives low to bot 1 and high to bot 0 value 3 goes to bot 1 bot 1 gives low to output 1 and high to bot 0 bot 0 gives low to output 2 and high to output 0 value 2 goes to bot 2 - """ -) + """) def test_who_compared() -> None: diff --git a/2017/Day_02/test_day02.py b/2017/Day_02/test_day02.py index 8225e70..e7c2ba1 100644 --- a/2017/Day_02/test_day02.py +++ b/2017/Day_02/test_day02.py @@ -6,13 +6,11 @@ PART_ONE_CASES = ( ( - dedent( - """\ + dedent("""\ 5 1 9 5 7 5 3 2 4 6 8 - """ - ).splitlines(), + """).splitlines(), 18, ), ) @@ -26,13 +24,11 @@ def test_part_one(raw_spreadsheet: list[str], truth_solution: int) -> None: PART_TWO_CASES = ( ( - dedent( - """\ + dedent("""\ 5 9 2 8 9 4 7 3 3 8 6 5 - """ - ).splitlines(), + """).splitlines(), 9, ), ) diff --git a/2017/Day_05/test_day05.py b/2017/Day_05/test_day05.py index 00b8bd6..adb9321 100644 --- a/2017/Day_05/test_day05.py +++ b/2017/Day_05/test_day05.py @@ -2,15 +2,13 @@ from .AoC2017_Day5 import follow_jumps, follow_strange_jumps -SAMPLE_OFFSETS = dedent( - """\ +SAMPLE_OFFSETS = dedent("""\ 0 3 0 1 -3 - """ -) + """) def test_part_one() -> None: diff --git a/2017/Day_07/test_day07.py b/2017/Day_07/test_day07.py index f739a81..cad57a9 100644 --- a/2017/Day_07/test_day07.py +++ b/2017/Day_07/test_day07.py @@ -2,8 +2,7 @@ from .AoC2017_Day7 import _build_tower, balance_tower, find_bottom_program -SAMPLE_TOWER = dedent( - """\ +SAMPLE_TOWER = dedent("""\ pbga (66) xhth (57) ebii (61) @@ -17,8 +16,7 @@ ugml (68) -> gyxo, ebii, jptl gyxo (61) cntj (57) - """ -).splitlines() + """).splitlines() TOWER = _build_tower(SAMPLE_TOWER) diff --git a/2017/Day_08/test_day08.py b/2017/Day_08/test_day08.py index 129f6c1..1a0db78 100644 --- a/2017/Day_08/test_day08.py +++ b/2017/Day_08/test_day08.py @@ -2,14 +2,12 @@ from .AoC2017_Day8 import execute -SAMPLE_INSTRUCTIONS = dedent( - """\ +SAMPLE_INSTRUCTIONS = dedent("""\ b inc 5 if a > 1 a inc 1 if b < 5 c dec -10 if a >= 1 c inc -20 if c == 10 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2018/Day_02/test_day02.py b/2018/Day_02/test_day02.py index e915f41..29c5818 100644 --- a/2018/Day_02/test_day02.py +++ b/2018/Day_02/test_day02.py @@ -2,8 +2,7 @@ from .aoc_2018_day2 import part1, part2 -PART_ONE_SAMPLE = dedent( - """\ +PART_ONE_SAMPLE = dedent("""\ abcdef bababc abbcde @@ -11,16 +10,14 @@ aabcdd abcdee ababab - """ -).splitlines() + """).splitlines() def test_part_one() -> None: assert part1(PART_ONE_SAMPLE) == 12 -PART_TWO_SAMPLE = dedent( - """\ +PART_TWO_SAMPLE = dedent("""\ abcde fghij klmno @@ -28,8 +25,7 @@ def test_part_one() -> None: fguij axcye wvxyz - """ -).splitlines() + """).splitlines() def test_part_two() -> None: diff --git a/2018/Day_03/test_day03.py b/2018/Day_03/test_day03.py index c66a8cc..48259dd 100644 --- a/2018/Day_03/test_day03.py +++ b/2018/Day_03/test_day03.py @@ -2,13 +2,11 @@ from .aoc_2018_day3 import _build_cloth, _parse_claims, calculate_overlap, find_nonoverlapping_claim -SAMPLE_CLAIMS = dedent( - """\ +SAMPLE_CLAIMS = dedent("""\ #1 @ 1,3: 4x4 #2 @ 3,1: 4x4 #3 @ 5,5: 2x2 - """ -).splitlines() + """).splitlines() CLAIMS = _parse_claims(SAMPLE_CLAIMS) CLOTH = _build_cloth(CLAIMS) diff --git a/2018/Day_04/test_day04.py b/2018/Day_04/test_day04.py index 2b77e0a..6b11867 100644 --- a/2018/Day_04/test_day04.py +++ b/2018/Day_04/test_day04.py @@ -7,8 +7,7 @@ find_sleepiest_minute, ) -SAMPLE_LOGS = dedent( - """\ +SAMPLE_LOGS = dedent("""\ [1518-11-01 00:00] Guard #10 begins shift [1518-11-01 00:05] falls asleep [1518-11-01 00:25] wakes up @@ -26,8 +25,7 @@ [1518-11-05 00:03] Guard #99 begins shift [1518-11-05 00:45] falls asleep [1518-11-05 00:55] wakes up - """ -).splitlines() + """).splitlines() LOGS = _parse_logs(SAMPLE_LOGS) SCHEDULE = _build_sleep_schedule(LOGS) diff --git a/2018/Day_06/test_day06.py b/2018/Day_06/test_day06.py index 07a84f6..f9bd9d8 100644 --- a/2018/Day_06/test_day06.py +++ b/2018/Day_06/test_day06.py @@ -7,16 +7,14 @@ parse_coordinates, ) -SAMPLE_COORDINATES = dedent( - """\ +SAMPLE_COORDINATES = dedent("""\ 1, 1 1, 6 8, 3 3, 4 5, 5 8, 9 - """ -) + """) def test_finite_areas() -> None: diff --git a/2018/Day_07/test_day07.py b/2018/Day_07/test_day07.py index b97f3d6..44abb0d 100644 --- a/2018/Day_07/test_day07.py +++ b/2018/Day_07/test_day07.py @@ -2,8 +2,7 @@ from .aoc_2018_day7 import _parse_edges, determine_step_order, elf_assembly -SAMPLE_INSTRUCTIONS = dedent( - """\ +SAMPLE_INSTRUCTIONS = dedent("""\ Step C must be finished before step A can begin. Step C must be finished before step F can begin. Step A must be finished before step B can begin. @@ -11,8 +10,7 @@ Step B must be finished before step E can begin. Step D must be finished before step E can begin. Step F must be finished before step E can begin. - """ -).splitlines() + """).splitlines() EDGES = _parse_edges(SAMPLE_INSTRUCTIONS) diff --git a/2019/Day_06/test_day6.py b/2019/Day_06/test_day6.py index b606327..dd99025 100644 --- a/2019/Day_06/test_day6.py +++ b/2019/Day_06/test_day6.py @@ -3,8 +3,7 @@ from aoc_2019_day6 import get_to_santa, n_total_orbits, system_from_orbits PART_ONE = ( - dedent( - """\ + dedent("""\ COM)B B)C C)D @@ -16,14 +15,12 @@ E)J J)K K)L - """ - ).splitlines(), + """).splitlines(), 42, ) PART_TWO = ( - dedent( - """\ + dedent("""\ COM)B B)C C)D @@ -37,8 +34,7 @@ K)L K)YOU I)SAN - """ - ).splitlines(), + """).splitlines(), 4, ) diff --git a/2019/Day_10/test_day10.py b/2019/Day_10/test_day10.py index e90f686..9102848 100644 --- a/2019/Day_10/test_day10.py +++ b/2019/Day_10/test_day10.py @@ -7,22 +7,19 @@ # Test cases provided as (asteroid map, truth x, truth y, truth asteroids seen) PART_ONE = [ ( - dedent( - """\ + dedent("""\ .#..# ..... ##### ....# ...## - """ - ), + """), 3, 4, 8, ), ( - dedent( - """\ + dedent("""\ ......#.#. #..#.#.... ..#######. @@ -33,15 +30,13 @@ .##.#..### ##...#..#. .#....#### - """ - ), + """), 5, 8, 33, ), ( - dedent( - """\ + dedent("""\ #.#...#.#. .###....#. .#....#... @@ -52,15 +47,13 @@ ..##....## ......#... .####.###. - """ - ), + """), 1, 2, 35, ), ( - dedent( - """\ + dedent("""\ .#..#..### ####.###.# ....###.#. @@ -71,15 +64,13 @@ #..#.#.### .##...##.# .....#.#.. - """ - ), + """), 6, 3, 41, ), ( - dedent( - """\ + dedent("""\ .#..##.###...####### ##.############..##. .#.######.########.# @@ -100,8 +91,7 @@ .#.#.###########.### #.#.#.#####.####.### ###.##.####.##.#..## - """ - ), + """), 11, 13, 210, @@ -111,8 +101,7 @@ # Test cases provided as (asteroid map, truth x, truth y) PART_TWO = [ ( - dedent( - """\ + dedent("""\ .#..##.###...####### ##.############..##. .#.######.########.# @@ -133,8 +122,7 @@ .#.#.###########.### #.#.#.#####.####.### ###.##.####.##.#..## - """ - ), + """), 8, 2, ), diff --git a/2019/Day_12/test_day12.py b/2019/Day_12/test_day12.py index a42bc45..9b34f12 100644 --- a/2019/Day_12/test_day12.py +++ b/2019/Day_12/test_day12.py @@ -6,26 +6,22 @@ # Provide test cases as (starting moon map, steps to simulate, truth energy) PART_ONE = [ ( - dedent( - """\ + dedent("""\ - """ - ), + """), 10, 179, ), ( - dedent( - """\ + dedent("""\ - """ - ), + """), 100, 1940, ), @@ -34,25 +30,21 @@ # Provide test cases as (starting moon map, truth steps) PART_TWO = [ ( - dedent( - """\ + dedent("""\ - """ - ), + """), 2772, ), ( - dedent( - """\ + dedent("""\ - """ - ), + """), 4686774924, ), ] diff --git a/2019/Day_14/test_day14.py b/2019/Day_14/test_day14.py index 9b8543a..992c3cc 100644 --- a/2019/Day_14/test_day14.py +++ b/2019/Day_14/test_day14.py @@ -6,21 +6,18 @@ # Test cases provided as (reaction list, ore required) PART_ONE = [ ( - dedent( - """\ + dedent("""\ 10 ORE => 10 A 1 ORE => 1 B 7 A, 1 B => 1 C 7 A, 1 C => 1 D 7 A, 1 D => 1 E 7 A, 1 E => 1 FUEL - """ - ), + """), 31, ), ( - dedent( - """\ + dedent("""\ 9 ORE => 2 A 8 ORE => 3 B 7 ORE => 5 C @@ -28,13 +25,11 @@ 5 B, 7 C => 1 BC 4 C, 1 A => 1 CA 2 AB, 3 BC, 4 CA => 1 FUEL - """ - ), + """), 165, ), ( - dedent( - """\ + dedent("""\ 157 ORE => 5 NZVS 165 ORE => 6 DCFZ 44 XJWVT, 5 KHKGT, 1 QDVJ, 29 NZVS, 9 GPVTF, 48 HKGWZ => 1 FUEL @@ -44,13 +39,11 @@ 7 DCFZ, 7 PSHF => 2 XJWVT 165 ORE => 2 GPVTF 3 DCFZ, 7 NZVS, 5 HKGWZ, 10 PSHF => 8 KHKGT - """ - ), + """), 13312, ), ( - dedent( - """\ + dedent("""\ 2 VPVL, 7 FWMGM, 2 CXFTF, 11 MNCFX => 1 STKFG 17 NVRVD, 3 JNWZP => 8 VPVL 53 STKFG, 6 MNCFX, 46 VJHF, 81 HVMC, 68 CXFTF, 25 GNMV => 1 FUEL @@ -63,13 +56,11 @@ 1 NVRVD => 8 CXFTF 1 VJHF, 6 MNCFX => 4 RFSQX 176 ORE => 6 VJHF - """ - ), + """), 180697, ), ( - dedent( - """\ + dedent("""\ 171 ORE => 8 CNZTR 7 ZLQW, 3 BMBT, 9 XCVML, 26 XMNCP, 1 WPTQ, 2 MZWV, 1 RJRHP => 4 PLWSL 114 ORE => 4 BHXH @@ -87,8 +78,7 @@ 121 ORE => 7 VRPVC 7 XCVML => 6 RJRHP 5 BHXH, 4 VRPVC => 5 LTCX - """ - ), + """), 2210736, ), ] @@ -97,8 +87,7 @@ # Test cases provided as (reaction list, fuel_produced) PART_TWO = [ ( - dedent( - """\ + dedent("""\ 157 ORE => 5 NZVS 165 ORE => 6 DCFZ 44 XJWVT, 5 KHKGT, 1 QDVJ, 29 NZVS, 9 GPVTF, 48 HKGWZ => 1 FUEL @@ -108,13 +97,11 @@ 7 DCFZ, 7 PSHF => 2 XJWVT 165 ORE => 2 GPVTF 3 DCFZ, 7 NZVS, 5 HKGWZ, 10 PSHF => 8 KHKGT - """ - ), + """), 82892753, ), ( - dedent( - """\ + dedent("""\ 2 VPVL, 7 FWMGM, 2 CXFTF, 11 MNCFX => 1 STKFG 17 NVRVD, 3 JNWZP => 8 VPVL 53 STKFG, 6 MNCFX, 46 VJHF, 81 HVMC, 68 CXFTF, 25 GNMV => 1 FUEL @@ -127,13 +114,11 @@ 1 NVRVD => 8 CXFTF 1 VJHF, 6 MNCFX => 4 RFSQX 176 ORE => 6 VJHF - """ - ), + """), 5586022, ), ( - dedent( - """\ + dedent("""\ 171 ORE => 8 CNZTR 7 ZLQW, 3 BMBT, 9 XCVML, 26 XMNCP, 1 WPTQ, 2 MZWV, 1 RJRHP => 4 PLWSL 114 ORE => 4 BHXH @@ -151,8 +136,7 @@ 121 ORE => 7 VRPVC 7 XCVML => 6 RJRHP 5 BHXH, 4 VRPVC => 5 LTCX - """ - ), + """), 460664, ), ] diff --git a/2020/Day_01/test_day01.py b/2020/Day_01/test_day01.py index d1ab2ed..804a6b3 100644 --- a/2020/Day_01/test_day01.py +++ b/2020/Day_01/test_day01.py @@ -2,16 +2,14 @@ from .aoc_2020_day01 import find_sum_combo -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 1721 979 366 299 675 1456 - """ -).splitlines() + """).splitlines() PUZZLE_INPUT = [int(line) for line in SAMPLE_INPUT] diff --git a/2020/Day_02/test_day02.py b/2020/Day_02/test_day02.py index cdb39e1..c5a24cc 100644 --- a/2020/Day_02/test_day02.py +++ b/2020/Day_02/test_day02.py @@ -16,13 +16,11 @@ class PasswordTestCase(t.NamedTuple): PASSWORD_TEST_CASES = [ PasswordTestCase( - dedent( - """\ + dedent("""\ 1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc - """ - ), + """), 2, 1, ), diff --git a/2020/Day_03/test_day03.py b/2020/Day_03/test_day03.py index 73a6d01..ed2d060 100644 --- a/2020/Day_03/test_day03.py +++ b/2020/Day_03/test_day03.py @@ -4,8 +4,7 @@ from .aoc_2020_day03 import TobogganMap -TOBOGGAN_MAP = dedent( - """\ +TOBOGGAN_MAP = dedent("""\ ..##....... #...#...#.. .#....#..#. @@ -17,8 +16,7 @@ #.##...#... #...##....# .#..#...#.# - """ -) + """) TOBOGGAN_RUN = TobogganMap(TOBOGGAN_MAP) diff --git a/2020/Day_04/test_day04.py b/2020/Day_04/test_day04.py index 11f40a6..e906d44 100644 --- a/2020/Day_04/test_day04.py +++ b/2020/Day_04/test_day04.py @@ -13,8 +13,7 @@ class PassportTestCase(t.NamedTuple): n_valid_passports: int -PT1_BATCH = dedent( - """\ +PT1_BATCH = dedent("""\ ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm @@ -28,8 +27,7 @@ class PassportTestCase(t.NamedTuple): hcl:#cfa07d eyr:2025 pid:166559648 iyr:2011 ecl:brn hgt:59in - """ -) + """) PASSPORT_TEST_CASES = [ PassportTestCase(("cid",), 2), @@ -48,8 +46,7 @@ def test_passport_validation_pt1(optional_fields: tuple[str], n_valid_passports: assert check_passports(passports, optional_fields) == n_valid_passports -PT2_INVALID = dedent( - """\ +PT2_INVALID = dedent("""\ eyr:1972 cid:100 hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926 @@ -63,11 +60,9 @@ def test_passport_validation_pt1(optional_fields: tuple[str], n_valid_passports: hgt:59cm ecl:zzz eyr:2038 hcl:74454a iyr:2023 pid:3556412378 byr:2007 - """ -) + """) -PT2_VALID = dedent( - """\ +PT2_VALID = dedent("""\ pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980 hcl:#623a2f @@ -80,8 +75,7 @@ def test_passport_validation_pt1(optional_fields: tuple[str], n_valid_passports: eyr:2022 iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719 - """ -) + """) def test_passport_validation_pt2() -> None: diff --git a/2020/Day_06/test_day06.py b/2020/Day_06/test_day06.py index e596ed6..8ac6aad 100644 --- a/2020/Day_06/test_day06.py +++ b/2020/Day_06/test_day06.py @@ -16,64 +16,52 @@ class CustomsTestCase(t.NamedTuple): FORM_TEST_CASES = [ CustomsTestCase( - dedent( - """\ + dedent("""\ abcx abcy abcz - """ - ), + """), 6, 3, ), CustomsTestCase( - dedent( - """\ + dedent("""\ abc - """ - ), + """), 3, 3, ), CustomsTestCase( - dedent( - """\ + dedent("""\ a b c - """ - ), + """), 3, 0, ), CustomsTestCase( - dedent( - """\ + dedent("""\ ab ac - """ - ), + """), 3, 1, ), CustomsTestCase( - dedent( - """\ + dedent("""\ a a a a - """ - ), + """), 1, 1, ), CustomsTestCase( - dedent( - """\ + dedent("""\ b - """ - ), + """), 1, 1, ), diff --git a/2020/Day_07/test_day07.py b/2020/Day_07/test_day07.py index 3c59f36..2e66882 100644 --- a/2020/Day_07/test_day07.py +++ b/2020/Day_07/test_day07.py @@ -16,8 +16,7 @@ class BagTestCase(t.NamedTuple): BAG_TEST_CASES = [ BagTestCase( - dedent( - """\ + dedent("""\ light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright white bags, 4 muted yellow bags. bright white bags contain 1 shiny gold bag. @@ -27,14 +26,12 @@ class BagTestCase(t.NamedTuple): vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. faded blue bags contain no other bags. dotted black bags contain no other bags. - """ - ), + """), 4, 32, ), BagTestCase( - dedent( - """\ + dedent("""\ shiny gold bags contain 2 dark red bags. dark red bags contain 2 dark orange bags. dark orange bags contain 2 dark yellow bags. @@ -42,8 +39,7 @@ class BagTestCase(t.NamedTuple): dark green bags contain 2 dark blue bags. dark blue bags contain 2 dark violet bags. dark violet bags contain no other bags. - """ - ), + """), 0, 126, ), diff --git a/2020/Day_08/test_day08.py b/2020/Day_08/test_day08.py index ed64929..47655ab 100644 --- a/2020/Day_08/test_day08.py +++ b/2020/Day_08/test_day08.py @@ -2,8 +2,7 @@ from .aoc_2020_day08 import GameGear, RepeatInstructionError, mutate_until_fixed -SAMPLE_INSTRUCTIONS = dedent( - """\ +SAMPLE_INSTRUCTIONS = dedent("""\ nop +0 acc +1 jmp +4 @@ -13,8 +12,7 @@ acc +1 jmp -4 acc +6 - """ -) + """) MACHINE = GameGear(SAMPLE_INSTRUCTIONS) diff --git a/2020/Day_09/test_day09.py b/2020/Day_09/test_day09.py index 05c6185..b995116 100644 --- a/2020/Day_09/test_day09.py +++ b/2020/Day_09/test_day09.py @@ -2,8 +2,7 @@ from .aoc_2020_day09 import find_weakness, process_stream -SAMPLE_STREAM = dedent( - """\ +SAMPLE_STREAM = dedent("""\ 35 20 15 @@ -24,8 +23,7 @@ 277 309 576 - """ -) + """) INT_STREAM = [int(line) for line in SAMPLE_STREAM.splitlines()] diff --git a/2020/Day_10/test_day10.py b/2020/Day_10/test_day10.py index c385be8..94d3564 100644 --- a/2020/Day_10/test_day10.py +++ b/2020/Day_10/test_day10.py @@ -15,8 +15,7 @@ class AdapterTestCase(t.NamedTuple): # noqa: D101 PUZZLE_TEST_CASES = [ AdapterTestCase( - dedent( - """\ + dedent("""\ 16 10 15 @@ -28,15 +27,13 @@ class AdapterTestCase(t.NamedTuple): # noqa: D101 6 12 4 - """ - ), + """), 7, 5, 8, ), AdapterTestCase( - dedent( - """\ + dedent("""\ 28 33 18 @@ -68,8 +65,7 @@ class AdapterTestCase(t.NamedTuple): # noqa: D101 34 10 3 - """ - ), + """), 22, 10, 19208, diff --git a/2020/Day_11/test_day11.py b/2020/Day_11/test_day11.py index df61770..3a1fa2d 100644 --- a/2020/Day_11/test_day11.py +++ b/2020/Day_11/test_day11.py @@ -2,8 +2,7 @@ from .aoc_2020_day11 import SeatMap, VisibleSeatMap -SEAT_LAYOUT = dedent( - """\ +SEAT_LAYOUT = dedent("""\ L.LL.LL.LL LLLLLLL.LL L.L.L..L.. @@ -14,8 +13,7 @@ LLLLLLLLLL L.LLLLLL.L L.LLLLL.LL - """ -) + """) def test_seat_stabilization() -> None: diff --git a/2020/Day_12/test_day12.py b/2020/Day_12/test_day12.py index b846a64..6ec10ee 100644 --- a/2020/Day_12/test_day12.py +++ b/2020/Day_12/test_day12.py @@ -2,15 +2,13 @@ from .aoc_2020_day12 import AdventFerry -SAMPLE_INSTRUCTIONS = dedent( - """\ +SAMPLE_INSTRUCTIONS = dedent("""\ F10 N3 F7 R90 F11 - """ -) + """) def test_ferry_driving() -> None: diff --git a/2020/Day_13/test_day13.py b/2020/Day_13/test_day13.py index 849fb97..5931bfd 100644 --- a/2020/Day_13/test_day13.py +++ b/2020/Day_13/test_day13.py @@ -4,12 +4,10 @@ from .aoc_2020_day13 import find_bus_id, find_golden_timestamp, parse_bus_schedule -SAMPLE_SCHEDULE = dedent( - """\ +SAMPLE_SCHEDULE = dedent("""\ 939 7,13,x,x,59,x,31,19 - """ -) + """) def test_part_one() -> None: # noqa: D103 diff --git a/2020/Day_14/test_day14.py b/2020/Day_14/test_day14.py index 19c9e40..da0de22 100644 --- a/2020/Day_14/test_day14.py +++ b/2020/Day_14/test_day14.py @@ -2,14 +2,12 @@ from .aoc_2020_day14 import FerryComputer -SAMPLE_PROGRAM = dedent( - """\ +SAMPLE_PROGRAM = dedent("""\ mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X mem[8] = 11 mem[7] = 101 mem[8] = 0 - """ -) + """) def test_part_one() -> None: # noqa: D103 @@ -19,14 +17,12 @@ def test_part_one() -> None: # noqa: D103 assert computer.initialization_value == 165 -PART_TWO_SAMPLE = dedent( - """\ +PART_TWO_SAMPLE = dedent("""\ mask = 000000000000000000000000000000X1001X mem[42] = 100 mask = 00000000000000000000000000000000X0XX mem[26] = 1 - """ -) + """) def test_part_two() -> None: # noqa: D103 diff --git a/2020/Day_16/test_day16.py b/2020/Day_16/test_day16.py index 91e03a8..dd22139 100644 --- a/2020/Day_16/test_day16.py +++ b/2020/Day_16/test_day16.py @@ -2,8 +2,7 @@ from .aoc_2020_day16 import calculate_error_rate, find_field_order, parse_puzzle_input -SAMPLE_INPUT_P1 = dedent( - """\ +SAMPLE_INPUT_P1 = dedent("""\ class: 1-3 or 5-7 row: 6-11 or 33-44 seat: 13-40 or 45-50 @@ -16,16 +15,14 @@ 40,4,50 55,2,20 38,6,12 - """ -) + """) def test_part_one() -> None: # noqa: D103 assert calculate_error_rate(SAMPLE_INPUT_P1) == 71 -SAMPLE_INPUT_P2 = dedent( - """\ +SAMPLE_INPUT_P2 = dedent("""\ class: 0-1 or 4-19 row: 0-5 or 8-19 seat: 0-13 or 16-19 @@ -37,8 +34,7 @@ def test_part_one() -> None: # noqa: D103 3,9,18 15,1,5 5,14,9 - """ -) + """) def test_part_two() -> None: # noqa: D103 diff --git a/2020/Day_17/test_day17.py b/2020/Day_17/test_day17.py index 9e4196e..3441e58 100644 --- a/2020/Day_17/test_day17.py +++ b/2020/Day_17/test_day17.py @@ -2,13 +2,11 @@ from .aoc_2020_day17 import ConwayCube -STARTING_SLICE = dedent( - """\ +STARTING_SLICE = dedent("""\ .#. ..# ### - """ -) + """) def test_part_one() -> None: # noqa: D103 diff --git a/2020/Day_19/test_day19.py b/2020/Day_19/test_day19.py index da7ca6d..fa4d06c 100644 --- a/2020/Day_19/test_day19.py +++ b/2020/Day_19/test_day19.py @@ -2,8 +2,7 @@ from .aoc_2020_day19 import check_messages -SAMPLE_1 = dedent( - """\ +SAMPLE_1 = dedent("""\ 0: 4 1 5 1: 2 3 | 3 2 2: 4 4 | 5 5 @@ -16,11 +15,9 @@ abbbab aaabbb aaaabbb - """ -) + """) -SAMPLE_2 = dedent( - """\ +SAMPLE_2 = dedent("""\ 42: 9 14 | 10 1 9: 14 27 | 1 26 10: 23 14 | 28 1 @@ -68,8 +65,7 @@ aaaabbaabbaaaaaaabbbabbbaaabbaabaaa babaaabbbaaabaababbaabababaaab aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba - """ -) + """) def test_part_one() -> None: # noqa: D103 diff --git a/2021/Day_01/test_day01.py b/2021/Day_01/test_day01.py index 2838a8a..ce9db8c 100644 --- a/2021/Day_01/test_day01.py +++ b/2021/Day_01/test_day01.py @@ -2,8 +2,7 @@ from .aoc_2021_day01 import count_ascending -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 199 200 208 @@ -14,8 +13,7 @@ 269 260 263 - """ -).splitlines() + """).splitlines() PUZZLE_INPUT = [int(line) for line in SAMPLE_INPUT] diff --git a/2021/Day_02/test_day02.py b/2021/Day_02/test_day02.py index a17eb4b..35e2a9b 100644 --- a/2021/Day_02/test_day02.py +++ b/2021/Day_02/test_day02.py @@ -2,16 +2,14 @@ from .aoc_2021_day02 import SubMcSubFace -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ forward 5 down 5 forward 8 up 3 down 8 forward 2 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_03/test_day03.py b/2021/Day_03/test_day03.py index c0cf3ba..2f61426 100644 --- a/2021/Day_03/test_day03.py +++ b/2021/Day_03/test_day03.py @@ -2,8 +2,7 @@ from .aoc_2021_day03 import calculate_life_support_rating, calculate_power_consumption -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 00100 11110 10110 @@ -16,8 +15,7 @@ 11001 00010 01010 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_04/test_day04.py b/2021/Day_04/test_day04.py index 4a9a2f4..df3f04e 100644 --- a/2021/Day_04/test_day04.py +++ b/2021/Day_04/test_day04.py @@ -2,8 +2,7 @@ from .aoc_2021_day04 import parse_bingo, run_bingo -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 22 13 17 11 0 @@ -23,8 +22,7 @@ 18 8 23 26 20 22 11 13 6 5 2 0 12 3 7 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_05/test_day05.py b/2021/Day_05/test_day05.py index 964f786..f6c139b 100644 --- a/2021/Day_05/test_day05.py +++ b/2021/Day_05/test_day05.py @@ -2,8 +2,7 @@ from .aoc_2021_day05 import find_overlaps -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 0,9 -> 5,9 8,0 -> 0,8 9,4 -> 3,4 @@ -14,8 +13,7 @@ 3,4 -> 1,4 0,0 -> 8,8 5,5 -> 8,2 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_06/test_day06.py b/2021/Day_06/test_day06.py index be93a9d..f80a49d 100644 --- a/2021/Day_06/test_day06.py +++ b/2021/Day_06/test_day06.py @@ -2,11 +2,9 @@ from .aoc_2021_day06 import spawn_until -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 3,4,3,1,2 - """ -).strip() + """).strip() AGES = [int(age) for age in SAMPLE_INPUT.split(",")] diff --git a/2021/Day_07/test_day07.py b/2021/Day_07/test_day07.py index 6829f53..cff669b 100644 --- a/2021/Day_07/test_day07.py +++ b/2021/Day_07/test_day07.py @@ -2,11 +2,9 @@ from .aoc_2021_day07 import min_horizontal_burn -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 16,1,2,0,4,2,7,1,2,14 - """ -).strip() + """).strip() DISTANCES = [int(distance) for distance in SAMPLE_INPUT.split(",")] diff --git a/2021/Day_08/test_day08.py b/2021/Day_08/test_day08.py index a261f4d..f9accbc 100644 --- a/2021/Day_08/test_day08.py +++ b/2021/Day_08/test_day08.py @@ -4,8 +4,7 @@ from .aoc_2021_day08 import Signal, determine_output, n_simple_outputs -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc @@ -17,8 +16,7 @@ bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce - """ -).splitlines() + """).splitlines() PARSED_SIGNALS = Signal.from_raw(SAMPLE_INPUT) diff --git a/2021/Day_09/test_day09.py b/2021/Day_09/test_day09.py index 05b43ca..e9f41bc 100644 --- a/2021/Day_09/test_day09.py +++ b/2021/Day_09/test_day09.py @@ -4,15 +4,13 @@ from .aoc_2021_day09 import find_low_points, n_largest_basins, parse_topography, total_risk_level -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 2199943210 3987894921 9856789892 8767896789 9899965678 - """ -).splitlines() + """).splitlines() TOPO_MAP = parse_topography(SAMPLE_INPUT) diff --git a/2021/Day_10/test_day10.py b/2021/Day_10/test_day10.py index 509a257..c76b63a 100644 --- a/2021/Day_10/test_day10.py +++ b/2021/Day_10/test_day10.py @@ -2,8 +2,7 @@ from .aoc_2021_day10 import parse_subsystem_code, score_autocomplete -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ [({(<(())[]>[[{[]{<()<>> [(()[<>])]({[<{<<[]>>( {([(<{}[<>[]}>{[]{[(<()> @@ -14,8 +13,7 @@ [<(<(<(<{}))><([]([]() <{([([[(<>()){}]>(<<{{ <{([{{}}[<[[[<>{}]]]>[]] - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_11/test_day11.py b/2021/Day_11/test_day11.py index 4c789c6..1513c9a 100644 --- a/2021/Day_11/test_day11.py +++ b/2021/Day_11/test_day11.py @@ -2,8 +2,7 @@ from .aoc_2021_day11 import find_first_sync, model_dumbo_cave, parse_energy_levels -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 5483143223 2745854711 5264556173 @@ -14,8 +13,7 @@ 6882881134 4846848554 5283751526 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_12/test_day12.py b/2021/Day_12/test_day12.py index 96357e4..38b8f29 100644 --- a/2021/Day_12/test_day12.py +++ b/2021/Day_12/test_day12.py @@ -6,8 +6,7 @@ TEST_CASES = [ ( - dedent( - """\ + dedent("""\ start-A start-b A-c @@ -15,14 +14,12 @@ b-d A-end b-end - """ - ).splitlines(), + """).splitlines(), 10, 36, ), ( - dedent( - """\ + dedent("""\ dc-end HN-start start-kj @@ -33,14 +30,12 @@ kj-sa kj-HN kj-dc - """ - ).splitlines(), + """).splitlines(), 19, 103, ), ( - dedent( - """\ + dedent("""\ fs-end he-DX fs-he @@ -59,8 +54,7 @@ zg-he pj-fs start-RW - """ - ).splitlines(), + """).splitlines(), 226, 3509, ), diff --git a/2021/Day_13/test_day13.py b/2021/Day_13/test_day13.py index eae28a6..584b263 100644 --- a/2021/Day_13/test_day13.py +++ b/2021/Day_13/test_day13.py @@ -2,8 +2,7 @@ from .aoc_2021_day13 import fold_paper, parse_instructions, prettyprint -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 6,10 0,14 9,10 @@ -25,8 +24,7 @@ fold along y=7 fold along x=5 - """ -) + """) DOT_COORDS, FOLDS = parse_instructions(SAMPLE_INPUT) @@ -34,14 +32,12 @@ def test_part_one() -> None: assert len(fold_paper(DOT_COORDS, [FOLDS[0]])) == 17 -EXPECTED_PRETTYPRINT = dedent( - """\ +EXPECTED_PRETTYPRINT = dedent("""\ ##### # # # # # # - #####""" -) + #####""") def test_part_two() -> None: diff --git a/2021/Day_14/test_day14.py b/2021/Day_14/test_day14.py index f35fad2..8a4fa4f 100644 --- a/2021/Day_14/test_day14.py +++ b/2021/Day_14/test_day14.py @@ -2,8 +2,7 @@ from .aoc_2021_day14 import non_brute_deconstruct, parse_polymer_formula -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ NNCB CH -> B @@ -22,8 +21,7 @@ BC -> B CC -> N CN -> C - """ -) + """) TEMPLATE, RULES = parse_polymer_formula(SAMPLE_INPUT) diff --git a/2021/Day_15/test_day15.py b/2021/Day_15/test_day15.py index acfdccc..1e65c5a 100644 --- a/2021/Day_15/test_day15.py +++ b/2021/Day_15/test_day15.py @@ -2,8 +2,7 @@ from .aoc_2021_day15 import find_route, parse_risk_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 1163751742 1381373672 2136511328 @@ -14,8 +13,7 @@ 3125421639 1293138521 2311944581 - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_18/test_day18.py b/2021/Day_18/test_day18.py index 6c6325f..9092e12 100644 --- a/2021/Day_18/test_day18.py +++ b/2021/Day_18/test_day18.py @@ -55,53 +55,44 @@ def test_snailfish_magnitude(snailfish_number: str, truth_magnitude: int) -> Non SUMMATION_TESTS = [ ( - dedent( - """\ + dedent("""\ [[[[4,3],4],4],[7,[[8,4],9]]] [1,1] - """ - ).splitlines(), + """).splitlines(), "[[[[0,7],4],[[7,8],[6,0]]],[8,1]]", ), ( - dedent( - """\ + dedent("""\ [1,1] [2,2] [3,3] [4,4] - """ - ).splitlines(), + """).splitlines(), "[[[[1,1],[2,2]],[3,3]],[4,4]]", ), ( - dedent( - """\ + dedent("""\ [1,1] [2,2] [3,3] [4,4] [5,5] - """ - ).splitlines(), + """).splitlines(), "[[[[3,0],[5,3]],[4,4]],[5,5]]", ), ( - dedent( - """\ + dedent("""\ [1,1] [2,2] [3,3] [4,4] [5,5] [6,6] - """ - ).splitlines(), + """).splitlines(), "[[[[5,0],[7,4]],[5,5]],[6,6]]", ), ( - dedent( - """\ + dedent("""\ [[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]] [7,[[[3,7],[4,3]],[[6,3],[8,8]]]] [[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]] @@ -112,13 +103,11 @@ def test_snailfish_magnitude(snailfish_number: str, truth_magnitude: int) -> Non [1,[[[9,3],9],[[9,0],[0,7]]]] [[[5,[7,4]],7],1] [[[[4,2],2],6],[8,7]] - """ - ).splitlines(), + """).splitlines(), "[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]", ), ( - dedent( - """\ + dedent("""\ [[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]] [[[5,[2,8]],4],[5,[[9,9],0]]] [6,[[[6,2],[5,6]],[[7,6],[4,7]]]] @@ -129,8 +118,7 @@ def test_snailfish_magnitude(snailfish_number: str, truth_magnitude: int) -> Non [[9,3],[[9,9],[6,[4,9]]]] [[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]] [[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]] - """ - ).splitlines(), + """).splitlines(), "[[[[6,6],[7,6]],[[7,7],[7,0]]],[[[7,7],[7,7]],[[7,8],[9,9]]]]", ), ] @@ -141,8 +129,7 @@ def test_summation(snailfish_numbers: list[str], truth_sum: str) -> None: assert calculate_sum(snailfish_numbers) == truth_sum -SAMPLE_HOMEWORK = dedent( - """\ +SAMPLE_HOMEWORK = dedent("""\ [[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]] [[[5,[2,8]],4],[5,[[9,9],0]]] [6,[[[6,2],[5,6]],[[7,6],[4,7]]]] @@ -153,8 +140,7 @@ def test_summation(snailfish_numbers: list[str], truth_sum: str) -> None: [[9,3],[[9,9],[6,[4,9]]]] [[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]] [[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]] - """ -).splitlines() + """).splitlines() def test_part_one() -> None: diff --git a/2021/Day_20/test_day20.py b/2021/Day_20/test_day20.py index 431f89f..0b9a367 100644 --- a/2021/Day_20/test_day20.py +++ b/2021/Day_20/test_day20.py @@ -2,8 +2,7 @@ from .aoc_2021_day20 import enhance_image, parse_input -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..# #..#. @@ -11,8 +10,7 @@ ##..# ..#.. ..### - """ -) + """) def test_part_one() -> None: diff --git a/2021/Day_21/test_day21.py b/2021/Day_21/test_day21.py index dc855c3..01972f2 100644 --- a/2021/Day_21/test_day21.py +++ b/2021/Day_21/test_day21.py @@ -2,12 +2,10 @@ from .aoc_2021_day21 import DiracDice, get_starting_positions, play_quantum -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Player 1 starting position: 4 Player 2 starting position: 8 - """ -) + """) def test_part_one() -> None: diff --git a/2021/Day_22/test_day22.py b/2021/Day_22/test_day22.py index fb42558..1f54ee4 100644 --- a/2021/Day_22/test_day22.py +++ b/2021/Day_22/test_day22.py @@ -11,20 +11,17 @@ SAMPLE_REBOOTS = [ ( - dedent( - """\ + dedent("""\ on x=10..12,y=10..12,z=10..12 on x=11..13,y=11..13,z=11..13 off x=9..11,y=9..11,z=9..11 on x=10..10,y=10..10,z=10..10 - """ - ).splitlines(), + """).splitlines(), 39, 39, ), ( - dedent( - """\ + dedent("""\ on x=-20..26,y=-36..17,z=-47..7 on x=-20..33,y=-21..23,z=-26..28 on x=-22..28,y=-29..23,z=-38..16 @@ -47,14 +44,12 @@ on x=-41..9,y=-7..43,z=-33..15 on x=-54112..-39298,y=-85059..-49293,z=-27449..7877 on x=967..23432,y=45373..81175,z=27513..53682 - """ - ).splitlines(), + """).splitlines(), 590_784, 39_769_202_357_779, ), ( - dedent( - """\ + dedent("""\ on x=-5..47,y=-31..22,z=-19..33 on x=-44..5,y=-27..21,z=-14..35 on x=-49..-1,y=-11..42,z=-10..38 @@ -115,8 +110,7 @@ off x=-70369..-16548,y=22648..78696,z=-1892..86821 on x=-53470..21291,y=-120233..-33476,z=-44150..38147 off x=-93533..-4276,y=-16170..68771,z=-104985..-24507 - """ - ).splitlines(), + """).splitlines(), 474_140, 2_758_514_936_282_235, ), diff --git a/2022/Day_01/test_day01.py b/2022/Day_01/test_day01.py index 9e5bd66..8cf36b7 100644 --- a/2022/Day_01/test_day01.py +++ b/2022/Day_01/test_day01.py @@ -2,8 +2,7 @@ from .aoc_2022_day01 import find_best_snack_trio, find_most_caloric_dense_elf, parse_puzzle_input -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 1000 2000 3000 @@ -18,8 +17,7 @@ 9000 10000 - """ -) + """) TRUTH_CALORIE_COUNT = [6_000, 4_000, 11_000, 24_000, 10_000] diff --git a/2022/Day_02/test_day02.py b/2022/Day_02/test_day02.py index 9b87236..007a24d 100644 --- a/2022/Day_02/test_day02.py +++ b/2022/Day_02/test_day02.py @@ -24,13 +24,11 @@ def test_round_score(round: str, truth_score: int) -> None: assert score_round(round) == truth_score -SAMPLE_GAME = dedent( - """\ +SAMPLE_GAME = dedent("""\ A Y B X C Z - """ -) + """) def test_total_score() -> None: diff --git a/2022/Day_03/test_day03.py b/2022/Day_03/test_day03.py index 6f0e8ec..075830c 100644 --- a/2022/Day_03/test_day03.py +++ b/2022/Day_03/test_day03.py @@ -20,16 +20,14 @@ def test_rucksack_check(rucksack: str, truth_priority: int) -> None: assert priority == truth_priority -SAMPLE_CONTENTS = dedent( - """\ +SAMPLE_CONTENTS = dedent("""\ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw - """ -) + """) def test_priority_check() -> None: @@ -38,36 +36,30 @@ def test_priority_check() -> None: SAMPLE_GROUPS = ( ( - dedent( - """\ + dedent("""\ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg - """ - ), + """), 18, ), ( - dedent( - """\ + dedent("""\ wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw - """ - ), + """), 52, ), ( - dedent( - """\ + dedent("""\ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw - """ - ), + """), 70, ), ) diff --git a/2022/Day_04/test_day04.py b/2022/Day_04/test_day04.py index c5049eb..ac1b508 100644 --- a/2022/Day_04/test_day04.py +++ b/2022/Day_04/test_day04.py @@ -20,16 +20,14 @@ def test_assignment_contain(assignments: str, is_fully_contained: bool) -> None: assert check_full_overlap(parsed) == is_fully_contained -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 2-4,6-8 2-3,4-5 5-7,7-9 2-8,3-7 6-6,4-6 2-6,4-8 - """ -) + """) def test_overlap_count() -> None: diff --git a/2022/Day_05/test_day05.py b/2022/Day_05/test_day05.py index 4bdae59..51cc6af 100644 --- a/2022/Day_05/test_day05.py +++ b/2022/Day_05/test_day05.py @@ -12,26 +12,22 @@ SAMPLE_STACKS = ( ( - dedent( - """\ + dedent("""\ [D] [N] [C] [Z] [M] [P] 1 2 3 - """ - ), + """), [["Z", "N"], ["M", "C", "D"], ["P"]], ), ( - dedent( - """\ + dedent("""\ [Z] [N] [M] [D] [C] [P] 1 2 3 - """ - ), + """), [["C", "M"], [], ["P", "D", "N", "Z"]], ), ) @@ -42,20 +38,17 @@ def test_stack_parse(stack_map: str, truth_stacks: list[list[str]]) -> None: assert _parse_stack_map(stack_map) == truth_stacks -SAMPLE_INSTRUCTIONS = dedent( - """\ +SAMPLE_INSTRUCTIONS = dedent("""\ move 1 from 2 to 1 move 3 from 1 to 3 - """ -) + """) def test_instruction_parse() -> None: assert _parse_instructions(SAMPLE_INSTRUCTIONS) == [Instruction(1, 1, 0), Instruction(3, 0, 2)] -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ [D] [N] [C] [Z] [M] [P] @@ -65,8 +58,7 @@ def test_instruction_parse() -> None: move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 - """ -) + """) def test_instruction_execute() -> None: diff --git a/2022/Day_07/test_day07.py b/2022/Day_07/test_day07.py index 3203810..855419b 100644 --- a/2022/Day_07/test_day07.py +++ b/2022/Day_07/test_day07.py @@ -4,8 +4,7 @@ from .aoc_2022_day07 import calculate_candidate_dir_size, find_best_deletion, parse_terminal_session -SAMPLE_SESSION = dedent( - """\ +SAMPLE_SESSION = dedent("""\ $ cd / $ ls dir a @@ -29,8 +28,7 @@ 8033020 d.log 5626152 d.ext 7214296 k - """ -) + """) DIR_SIZES = parse_terminal_session(SAMPLE_SESSION.splitlines()) diff --git a/2022/Day_08/test_day08.py b/2022/Day_08/test_day08.py index 364d6b3..5bb4601 100644 --- a/2022/Day_08/test_day08.py +++ b/2022/Day_08/test_day08.py @@ -2,15 +2,13 @@ from .aoc_2022_day08 import count_visible_trees, find_max_scenic_score, parse_tree_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 30373 25512 65332 33549 35390 - """ -) + """) TREE_MAP = parse_tree_map(SAMPLE_INPUT) diff --git a/2022/Day_09/test_day09.py b/2022/Day_09/test_day09.py index e0c467b..0b0a0cd 100644 --- a/2022/Day_09/test_day09.py +++ b/2022/Day_09/test_day09.py @@ -6,8 +6,7 @@ SAMPLE_INPUTS = ( ( - dedent( - """\ + dedent("""\ R 4 U 4 L 3 @@ -16,14 +15,12 @@ D 1 L 5 R 2 - """ - ), + """), 13, 1, ), ( - dedent( - """\ + dedent("""\ R 5 U 8 L 8 @@ -32,8 +29,7 @@ D 10 L 25 U 20 - """ - ), + """), 88, 36, ), diff --git a/2022/Day_10/test_day10.py b/2022/Day_10/test_day10.py index d56335c..1e15831 100644 --- a/2022/Day_10/test_day10.py +++ b/2022/Day_10/test_day10.py @@ -12,15 +12,13 @@ def test_part_one() -> None: assert sum(debug_register(SAMPLE_INPUT, QUERY_CYCLES)) == 13140 -SAMPLE_IMAGE = dedent( - """\ +SAMPLE_IMAGE = dedent("""\ ##..##..##..##..##..##..##..##..##..##.. ###...###...###...###...###...###...###. ####....####....####....####....####.... #####.....#####.....#####.....#####..... ######......######......######......#### - #######.......#######.......#######.....""" -) + #######.......#######.......#######.....""") def test_part_two() -> None: diff --git a/2022/Day_11/test_day11.py b/2022/Day_11/test_day11.py index f7cda01..ec69b5a 100644 --- a/2022/Day_11/test_day11.py +++ b/2022/Day_11/test_day11.py @@ -2,8 +2,7 @@ from .aoc_2022_day11 import MonkeyGame -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Monkey 0: Starting items: 79, 98 Operation: new = old * 19 @@ -31,8 +30,7 @@ Test: divisible by 17 If true: throw to monkey 0 If false: throw to monkey 1 - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_12/test_day12.py b/2022/Day_12/test_day12.py index 32369e0..4d74657 100644 --- a/2022/Day_12/test_day12.py +++ b/2022/Day_12/test_day12.py @@ -4,15 +4,13 @@ from .aoc_2022_day12 import build_valid_steps, find_shortest_hike, parse_map -SAMPLE_MAP = dedent( - """ +SAMPLE_MAP = dedent(""" Sabqponm abcryxxl accszExk acctuvwj abdefghi - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_13/test_day13.py b/2022/Day_13/test_day13.py index 79573b2..3f1c8b8 100644 --- a/2022/Day_13/test_day13.py +++ b/2022/Day_13/test_day13.py @@ -35,8 +35,7 @@ def test_comparisons(left: list, right: list, truth_comp: bool) -> None: assert (check_order(left, right) < 0) == truth_comp -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ [1,1,3,1,1] [1,1,5,1,1] @@ -60,8 +59,7 @@ def test_comparisons(left: list, right: list, truth_comp: bool) -> None: [1,[2,[3,[4,[5,6,7]]]],8,9] [1,[2,[3,[4,[5,6,0]]]],8,9] - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_14/test_day14.py b/2022/Day_14/test_day14.py index b734ecd..d929815 100644 --- a/2022/Day_14/test_day14.py +++ b/2022/Day_14/test_day14.py @@ -2,12 +2,10 @@ from .aoc_2022_day14 import fill_until_blocked, parse_rock_traces, simulate_sand_fill -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 498,4 -> 498,6 -> 496,6 503,4 -> 502,4 -> 502,9 -> 494,9 - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_15/test_day15.py b/2022/Day_15/test_day15.py index 9ef93f8..7f23719 100644 --- a/2022/Day_15/test_day15.py +++ b/2022/Day_15/test_day15.py @@ -2,8 +2,7 @@ from .aoc_2022_day15 import SensorField, identify_tuning_frequency, n_nonbeacon_1d, parse_sensor_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Sensor at x=2, y=18: closest beacon is at x=-2, y=15 Sensor at x=9, y=16: closest beacon is at x=10, y=16 Sensor at x=13, y=2: closest beacon is at x=15, y=3 @@ -18,8 +17,7 @@ Sensor at x=16, y=7: closest beacon is at x=15, y=3 Sensor at x=14, y=3: closest beacon is at x=15, y=3 Sensor at x=20, y=1: closest beacon is at x=15, y=3 - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_16/test_day16.py b/2022/Day_16/test_day16.py index 3d31b5d..63caf45 100644 --- a/2022/Day_16/test_day16.py +++ b/2022/Day_16/test_day16.py @@ -1,7 +1,6 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Valve AA has flow rate=0; tunnels lead to valves DD, II, BB Valve BB has flow rate=13; tunnels lead to valves CC, AA Valve CC has flow rate=2; tunnels lead to valves DD, BB @@ -12,5 +11,4 @@ Valve HH has flow rate=22; tunnel leads to valve GG Valve II has flow rate=0; tunnels lead to valves AA, JJ Valve JJ has flow rate=21; tunnel leads to valve II - """ -) + """) diff --git a/2022/Day_17/aoc_2022_day17.py b/2022/Day_17/aoc_2022_day17.py index 9ed8c74..43b69aa 100644 --- a/2022/Day_17/aoc_2022_day17.py +++ b/2022/Day_17/aoc_2022_day17.py @@ -43,8 +43,7 @@ def from_raw(cls, raw_spec: str) -> Elfomino: return cls(coords) -SHAPE_SPEC = dedent( - """\ +SHAPE_SPEC = dedent("""\ #### .#. @@ -62,8 +61,7 @@ def from_raw(cls, raw_spec: str) -> Elfomino: ## ## - """ -) + """) PIECES = tuple(Elfomino.from_raw(piece) for piece in SHAPE_SPEC.split("\n\n")) diff --git a/2022/Day_18/test_day18.py b/2022/Day_18/test_day18.py index cf7cd11..36eb4c8 100644 --- a/2022/Day_18/test_day18.py +++ b/2022/Day_18/test_day18.py @@ -6,17 +6,14 @@ SAMPLE_GRIDS = ( ( - dedent( - """\ + dedent("""\ 1,1,1 2,1,1 - """ - ), + """), 10, ), ( - dedent( - """\ + dedent("""\ 2,2,2 1,2,2 3,2,2 @@ -30,8 +27,7 @@ 3,2,5 2,1,5 2,3,5 - """ - ), + """), 64, ), ) @@ -43,8 +39,7 @@ def test_part_one(lava_scan: str, truth_sides: int) -> None: assert calc_surface_area(cubes) == truth_sides -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 2,2,2 1,2,2 3,2,2 @@ -58,8 +53,7 @@ def test_part_one(lava_scan: str, truth_sides: int) -> None: 3,2,5 2,1,5 2,3,5 - """ -) + """) def test_part_two() -> None: diff --git a/2022/Day_19/test_day19.py b/2022/Day_19/test_day19.py index 65d5aba..b0c513f 100644 --- a/2022/Day_19/test_day19.py +++ b/2022/Day_19/test_day19.py @@ -1,8 +1,6 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian. Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian. - """ -) + """) diff --git a/2022/Day_20/test_day20.py b/2022/Day_20/test_day20.py index f63aeca..a165aac 100644 --- a/2022/Day_20/test_day20.py +++ b/2022/Day_20/test_day20.py @@ -2,8 +2,7 @@ from .aoc_2022_day20 import DECRYPTION_KEY, decrypt, parse_file -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 1 2 -3 @@ -11,8 +10,7 @@ -2 0 4 - """ -) + """) ENCRYPTED = parse_file(SAMPLE_INPUT) diff --git a/2022/Day_21/test_day21.py b/2022/Day_21/test_day21.py index 8656ac1..936037c 100644 --- a/2022/Day_21/test_day21.py +++ b/2022/Day_21/test_day21.py @@ -1,7 +1,6 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ root: pppw + sjmn dbpl: 5 cczh: sllz + lgvd @@ -17,5 +16,4 @@ lgvd: ljgn * ptdq drzm: hmdt - zczc hmdt: 32 - """ -) + """) diff --git a/2022/Day_22/test_day22.py b/2022/Day_22/test_day22.py index 5317ee0..3aa84fc 100644 --- a/2022/Day_22/test_day22.py +++ b/2022/Day_22/test_day22.py @@ -2,8 +2,7 @@ from .aoc_2022_day22 import find_password, parse_puzzle_input -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ...# .#.. #... @@ -18,8 +17,7 @@ ......#. 10R5L5R10L4R5L5 - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_23/test_day23.py b/2022/Day_23/test_day23.py index 82b46c4..4ce4a36 100644 --- a/2022/Day_23/test_day23.py +++ b/2022/Day_23/test_day23.py @@ -3,8 +3,7 @@ from helpers.parsing import parse_hashed_map from .aoc_2022_day23 import run_sim, run_until_static -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ....#.. ..###.# #...#.# @@ -12,8 +11,7 @@ #.###.. ##.#.## .#..#.. - """ -) + """) def test_part_one() -> None: diff --git a/2022/Day_24/test_day24.py b/2022/Day_24/test_day24.py index f4b1b87..6debe5d 100644 --- a/2022/Day_24/test_day24.py +++ b/2022/Day_24/test_day24.py @@ -1,12 +1,10 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ #.###### #>>.<^<# #.<..<<# #>v.><># #<^v^^># ######.# - """ -) + """) diff --git a/2022/Day_25/test_day25.py b/2022/Day_25/test_day25.py index 3a745f9..a4ff2f0 100644 --- a/2022/Day_25/test_day25.py +++ b/2022/Day_25/test_day25.py @@ -50,8 +50,7 @@ def test_snafu_to_decimal(snafu_val: str, truth_decimal: int) -> None: assert snafu2dec(snafu_val) == truth_decimal -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 1=-0-2 12111 2=0= @@ -65,8 +64,7 @@ def test_snafu_to_decimal(snafu_val: str, truth_decimal: int) -> None: 12 1= 122 - """ -) + """) def test_part_one() -> None: diff --git a/2023/Day_02/test_day02.py b/2023/Day_02/test_day02.py index 3889d7d..bbccbfe 100644 --- a/2023/Day_02/test_day02.py +++ b/2023/Day_02/test_day02.py @@ -19,15 +19,13 @@ def test_valid_game(game_spec: str, truth_is_valid: bool) -> None: assert g.is_possible(red=12, green=13, blue=14) is truth_is_valid -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green - """ -) + """) def test_valid_games() -> None: diff --git a/2023/Day_03/test_day03.py b/2023/Day_03/test_day03.py index 22e3152..42cce12 100644 --- a/2023/Day_03/test_day03.py +++ b/2023/Day_03/test_day03.py @@ -2,8 +2,7 @@ from .aoc_2023_day03 import find_adjacent_parts, find_gears, parse_schematic, sum_gear_ratios -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 467..114.. ...*...... ..35..633. @@ -14,8 +13,7 @@ ......755. ...$.*.... .664.598.. - """ -) + """) TRUTH_N_SYMBOLS = sum(1 for c in SAMPLE_INPUT if c in {"*", "#", "+", "$"}) @@ -33,13 +31,11 @@ def test_adjacent_parts() -> None: assert not (emitted_set & {141, 58}) # 114 and 58 aren't valid part numbers -SAMPLE_ADJACENT = dedent( - """\ +SAMPLE_ADJACENT = dedent("""\ 467..114.. ...*...... 467..123.. - """ -) + """) def test_multiple_part_instances() -> None: diff --git a/2023/Day_04/test_day04.py b/2023/Day_04/test_day04.py index 145cb91..bdac4f8 100644 --- a/2023/Day_04/test_day04.py +++ b/2023/Day_04/test_day04.py @@ -21,16 +21,14 @@ def test_card_parsing(card_spec: str, truth_n_matching: int, truth_score: int) - assert card.value == truth_score -SAMPLE_CARDS = dedent( - """\ +SAMPLE_CARDS = dedent("""\ Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1 Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83 Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36 Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11 - """ -) + """) def test_bulk_score() -> None: diff --git a/2023/Day_05/test_day05.py b/2023/Day_05/test_day05.py index 942064d..7dafdeb 100644 --- a/2023/Day_05/test_day05.py +++ b/2023/Day_05/test_day05.py @@ -21,8 +21,7 @@ def test_mapping_parse(map_str: str, truth_src: list[int], truth_dest: list[int] assert [mapping[src_idx] for src_idx in mapping._source_range] == truth_dest -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ seeds: 79 14 55 13 seed-to-soil map: @@ -56,8 +55,7 @@ def test_mapping_parse(map_str: str, truth_src: list[int], truth_dest: list[int] humidity-to-location map: 60 56 37 56 93 4 - """ -) + """) TRUTH_END_STATE = ( (79, 81, 81, 81, 74, 78, 78, 82), diff --git a/2023/Day_06/test_day06.py b/2023/Day_06/test_day06.py index feaceee..6730461 100644 --- a/2023/Day_06/test_day06.py +++ b/2023/Day_06/test_day06.py @@ -5,12 +5,10 @@ from .aoc_2023_day06 import RaceSpec, winning_strategies -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Time: 7 15 30 Distance: 9 40 200 - """ -) + """) TRUTH_SPECS = ( (7, 9), diff --git a/2023/Day_07/test_day07.py b/2023/Day_07/test_day07.py index 9872ac3..2d2ec80 100644 --- a/2023/Day_07/test_day07.py +++ b/2023/Day_07/test_day07.py @@ -20,15 +20,13 @@ def test_hand_parsing(player_spec: str, truth_kind: HandType, truth_bid: int) -> assert p.bid == truth_bid -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 32T3K 765 T55J5 684 KK677 28 KTJJT 220 QQQJA 483 - """ -) + """) TRUTH_RANKING = (1, 4, 3, 2, 5) TRUTH_WINNINGS = 6440 diff --git a/2023/Day_08/test_day08.py b/2023/Day_08/test_day08.py index bd3f7ca..fbe1842 100644 --- a/2023/Day_08/test_day08.py +++ b/2023/Day_08/test_day08.py @@ -4,8 +4,7 @@ from .aoc_2023_day08 import parse_map, traverse_as_ghost, traverse_as_ghost_bf, traverse_map -SAMPLE_MAP_1 = dedent( - """\ +SAMPLE_MAP_1 = dedent("""\ RL AAA = (BBB, CCC) @@ -15,18 +14,15 @@ EEE = (EEE, EEE) GGG = (GGG, GGG) ZZZ = (ZZZ, ZZZ) - """ -) + """) -SAMPLE_MAP_2 = dedent( - """\ +SAMPLE_MAP_2 = dedent("""\ LLR AAA = (BBB, BBB) BBB = (AAA, ZZZ) ZZZ = (ZZZ, ZZZ) - """ -) + """) def test_map_parse() -> None: @@ -47,8 +43,7 @@ def test_map_traversal(raw_map: str, truth_n_steps: int) -> None: assert traverse_map(instructions, nodes) == truth_n_steps -SAMPLE_MAP_GHOSTS = dedent( - """\ +SAMPLE_MAP_GHOSTS = dedent("""\ LR 11A = (11B, XXX) @@ -59,8 +54,7 @@ def test_map_traversal(raw_map: str, truth_n_steps: int) -> None: 22C = (22Z, 22Z) 22Z = (22B, 22B) XXX = (XXX, XXX) - """ -) + """) def test_ghost_traversal() -> None: diff --git a/2023/Day_10/test_day10.py b/2023/Day_10/test_day10.py index bd6c8d8..2272a11 100644 --- a/2023/Day_10/test_day10.py +++ b/2023/Day_10/test_day10.py @@ -4,45 +4,37 @@ from .aoc_2023_day10 import find_furthest_loop_point, n_enclosed_tiles, parse_map -SAMPLE_INPUT_1 = dedent( - """\ +SAMPLE_INPUT_1 = dedent("""\ ..... .S-7. .|.|. .L-J. ..... - """ -) + """) -SAMPLE_INPUT_2 = dedent( - """\ +SAMPLE_INPUT_2 = dedent("""\ -L|F7 7S-7| L|7|| -L-J| L|-JF - """ -) + """) -SAMPLE_INPUT_3 = dedent( - """\ +SAMPLE_INPUT_3 = dedent("""\ ..F7. .FJ|. SJ.L7 |F--J LJ... - """ -) + """) -SAMPLE_INPUT_4 = dedent( - """\ +SAMPLE_INPUT_4 = dedent("""\ 7-F7- .FJ|7 SJLL7 |F--J LJ.LJ - """ -) + """) TEST_CASES = ( (SAMPLE_INPUT_1, 4), @@ -58,8 +50,7 @@ def test_furthest_distance(pipe_map: str, truth_furthest_distance: int) -> None: assert find_furthest_loop_point(pipe_graph, animal_start) == truth_furthest_distance -SQUEEZE_SAMPLE_1 = dedent( - """\ +SQUEEZE_SAMPLE_1 = dedent("""\ ........... .S-------7. .|F-----7|. @@ -69,11 +60,9 @@ def test_furthest_distance(pipe_map: str, truth_furthest_distance: int) -> None: .|..|.|..|. .L--J.L--J. ........... - """ -) + """) -SQUEEZE_SAMPLE_2 = dedent( - """\ +SQUEEZE_SAMPLE_2 = dedent("""\ .......... .S------7. .|F----7|. @@ -83,11 +72,9 @@ def test_furthest_distance(pipe_map: str, truth_furthest_distance: int) -> None: .|..||..|. .L--JL--J. .......... - """ -) + """) -SQUEEZE_SAMPLE_3 = dedent( - """\ +SQUEEZE_SAMPLE_3 = dedent("""\ .F----7F7F7F7F-7.... .|F--7||||||||FJ.... .||.FJ||||||||L7.... @@ -98,11 +85,9 @@ def test_furthest_distance(pipe_map: str, truth_furthest_distance: int) -> None: .....|FJLJ|FJ|F7|.LJ ....FJL-7.||.||||... ....L---J.LJ.LJLJ... - """ -) + """) -SQUEEZE_SAMPLE_4 = dedent( - """\ +SQUEEZE_SAMPLE_4 = dedent("""\ FF7FSF7F7F7F7F7F---7 L|LJ||||||||||||F--J FL-7LJLJ||||||LJL-77 @@ -113,8 +98,7 @@ def test_furthest_distance(pipe_map: str, truth_furthest_distance: int) -> None: 7-L-JL7||F7|L7F-7F7| L.L7LFJ|||||FJL7||LJ L7JLJL-JLJLJL--JLJ.L - """ -) + """) SQUEEZE_TEST_CASES = ( (SQUEEZE_SAMPLE_1, 4), diff --git a/2023/Day_11/test_day11.py b/2023/Day_11/test_day11.py index 270fb64..71c41c0 100644 --- a/2023/Day_11/test_day11.py +++ b/2023/Day_11/test_day11.py @@ -5,8 +5,7 @@ from helpers.geometry import COORD from .aoc_2023_day11 import galaxy_dist, parse_galaxy_map, sum_galaxy_pdist -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ...#...... .......#.. #......... @@ -17,11 +16,9 @@ .......... .......#.. #...#..... - """ -) + """) -TRUTH_EXPANDED = dedent( - """\ +TRUTH_EXPANDED = dedent("""\ ....1........ .........2... 3............ @@ -34,8 +31,7 @@ ............. .........7... 8....9....... - """ -) + """) TRUTH_COORDS = set() for y, line in enumerate(TRUTH_EXPANDED.splitlines()): for x, c in enumerate(line): diff --git a/2023/Day_13/test_day13.py b/2023/Day_13/test_day13.py index f49213c..4f5e179 100644 --- a/2023/Day_13/test_day13.py +++ b/2023/Day_13/test_day13.py @@ -4,8 +4,7 @@ from .aoc_2023_day13 import Pattern, find_reflections, parse_patterns, summarize_patterns -SAMPLE_INPUT_EXTENDED = dedent( - """\ +SAMPLE_INPUT_EXTENDED = dedent("""\ #.##..##. ..#.##.#. ##......# @@ -39,8 +38,7 @@ ...#....#...### ##...##...##### ....#.......... - """ -) + """) PATTERNS = parse_patterns(SAMPLE_INPUT_EXTENDED) REFLECTION_TEST_CASES = ( # type: ignore[var-annotated] @@ -55,8 +53,7 @@ def test_find_reflection(pattern: Pattern, truth_reflection: tuple[list[int], li assert find_reflections(pattern) == truth_reflection -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ #.##..##. ..#.##.#. ##......# @@ -72,8 +69,7 @@ def test_find_reflection(pattern: Pattern, truth_reflection: tuple[list[int], li #####.##. ..##..### #....#..# - """ -) + """) def test_summarize() -> None: diff --git a/2023/Day_14/test_day14.py b/2023/Day_14/test_day14.py index d837f52..d670a6d 100644 --- a/2023/Day_14/test_day14.py +++ b/2023/Day_14/test_day14.py @@ -2,8 +2,7 @@ from .aoc_2023_day14 import PlatformMap, TiltDirection -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ O....#.... O.OO#....# .....##... @@ -14,8 +13,7 @@ .......O.. #....###.. #OO..#.... - """ -) + """) def test_support_load() -> None: diff --git a/2023/Day_17/test_day17.py b/2023/Day_17/test_day17.py index 49a947b..7027f39 100644 --- a/2023/Day_17/test_day17.py +++ b/2023/Day_17/test_day17.py @@ -5,8 +5,7 @@ from helpers.geometry import COORD from .aoc_2023_day17 import minimize_heat_loss, parse_heat_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 2413432311323 3215453535623 3255245654254 @@ -20,8 +19,7 @@ 1224686865563 2546548887735 4322674655533 - """ -) + """) HEAT_MAP = parse_heat_map(SAMPLE_INPUT) @@ -29,8 +27,7 @@ def test_minimized_path() -> None: assert minimize_heat_loss(HEAT_MAP) == 102 -ULTRA_SAMPLE_1 = dedent( - """\ +ULTRA_SAMPLE_1 = dedent("""\ 2413432311323 3215453535623 3255245654254 @@ -44,18 +41,15 @@ def test_minimized_path() -> None: 1224686865563 2546548887735 4322674655533 - """ -) + """) -ULTRA_SAMPLE_2 = dedent( - """\ +ULTRA_SAMPLE_2 = dedent("""\ 111111111111 999999999991 999999999991 999999999991 999999999991 - """ -) + """) ULTRA_CRUCIBLE_CASES = ( (parse_heat_map(ULTRA_SAMPLE_1), 94), diff --git a/2023/Day_18/test_day18.py b/2023/Day_18/test_day18.py index 892edcc..b34811f 100644 --- a/2023/Day_18/test_day18.py +++ b/2023/Day_18/test_day18.py @@ -5,8 +5,7 @@ from helpers.geometry import MoveDir from .aoc_2023_day18 import Instruction, dig_trench, parse_dig_instructions -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ R 6 (#70c710) D 5 (#0dc571) L 2 (#5713f0) @@ -21,8 +20,7 @@ U 3 (#a77fa3) L 2 (#015232) U 2 (#7a21e3) - """ -) + """) INSTRUCTIONS = parse_dig_instructions(SAMPLE_INPUT) diff --git a/2023/Day_19/test_day19.py b/2023/Day_19/test_day19.py index 0a7c287..dcc81e3 100644 --- a/2023/Day_19/test_day19.py +++ b/2023/Day_19/test_day19.py @@ -3,8 +3,7 @@ from .aoc_2023_day19 import parse_instructions, sort_parts -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ px{a<2006:qkq,m>2090:A,rfg} pv{a>1716:R,A} lnx{m>1548:A,A} @@ -22,8 +21,7 @@ {x=2036,m=264,a=79,s=2244} {x=2461,m=1339,a=466,s=291} {x=2127,m=1623,a=2188,s=1013} - """ -) + """) def test_rating_sum() -> None: diff --git a/2023/Day_20/test_day20.py b/2023/Day_20/test_day20.py index e9a6e59..d95dec0 100644 --- a/2023/Day_20/test_day20.py +++ b/2023/Day_20/test_day20.py @@ -4,25 +4,21 @@ from .aoc_2023_day20 import parse_module_configuration, press_button -SAMPLE_INPUT_1 = dedent( - """\ +SAMPLE_INPUT_1 = dedent("""\ broadcaster -> a, b, c %a -> b %b -> c %c -> inv &inv -> a - """ -) + """) -SAMPLE_INPUT_2 = dedent( - """\ +SAMPLE_INPUT_2 = dedent("""\ broadcaster -> a %a -> inv, con &inv -> b %b -> con &con -> output - """ -) + """) BUTTON_PRESS_TEST_CASES = ( (SAMPLE_INPUT_1, 32, 32_000_000), diff --git a/2023/Day_21/test_day21.py b/2023/Day_21/test_day21.py index 5f22db1..2c01267 100644 --- a/2023/Day_21/test_day21.py +++ b/2023/Day_21/test_day21.py @@ -4,8 +4,7 @@ from .aoc_2023_day21 import build_garden_network, parse_garden_map, step_search -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ........... .....###.#. .###.##..#. @@ -17,8 +16,7 @@ .##.#.####. .##..##.##. ........... - """ -) + """) def test_map_parsing() -> None: diff --git a/2024/Day_01/test_day01.py b/2024/Day_01/test_day01.py index 7b5d32a..6ab2dc6 100644 --- a/2024/Day_01/test_day01.py +++ b/2024/Day_01/test_day01.py @@ -2,20 +2,14 @@ from .aoc_2024_day01 import calculate_similarity_score, calculate_total_distance, split_id_locations -SAMPLE_INPUT = ( - dedent( - """\ +SAMPLE_INPUT = dedent("""\ 3 4 4 3 2 5 1 3 3 9 3 3 - """ - ) - .strip() - .splitlines() -) + """).strip().splitlines() def test_split_id_locations() -> None: diff --git a/2024/Day_02/test_day02.py b/2024/Day_02/test_day02.py index fef0a66..fc0ffa8 100644 --- a/2024/Day_02/test_day02.py +++ b/2024/Day_02/test_day02.py @@ -4,16 +4,14 @@ from .aoc_2024_day02 import is_level_safe, is_level_safe_with_dampener, parse_level_report -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 7 6 4 2 1 1 2 7 8 9 9 7 6 2 1 1 3 2 4 5 8 6 4 4 1 1 3 6 7 9 - """ -).strip() + """).strip() def test_report_parse() -> None: diff --git a/2024/Day_04/test_day04.py b/2024/Day_04/test_day04.py index 2266776..4187f66 100644 --- a/2024/Day_04/test_day04.py +++ b/2024/Day_04/test_day04.py @@ -4,15 +4,13 @@ from .aoc_2024_day04 import count_word, count_x_mas, parse_word_search -SAMPLE_INPUT_1 = dedent( - """\ +SAMPLE_INPUT_1 = dedent("""\ ..X... .SAMX. .A..A. XMAS.S .X.... - """ -) + """) TRUTH_COORDS_SAMPLE_1 = { "X": {(0, 3), (2, 0), (1, 4), (4, 1)}, @@ -30,8 +28,7 @@ def test_parse_word_search() -> None: assert letter_map == TRUTH_COORDS_SAMPLE_1 -SAMPLE_INPUT_2 = dedent( - """\ +SAMPLE_INPUT_2 = dedent("""\ MMMSXXMASM MSAMXMSMSA AMXSXMAAMM @@ -42,11 +39,9 @@ def test_parse_word_search() -> None: SAXAMASAAA MAMMMXMMMM MXMXAXMASX - """ -) + """) -SAMPLE_INPUT_3 = dedent( - """\ +SAMPLE_INPUT_3 = dedent("""\ ....XXMAS. .SAMXMS... ...S..A... @@ -57,8 +52,7 @@ def test_parse_word_search() -> None: .A.A.A.A.A ..M.M.M.MM .X.X.XMASX - """ -) + """) COUNTING_TEST_CASES = ( (SAMPLE_INPUT_1, 4), @@ -73,8 +67,7 @@ def test_count_xmas(raw_puzzle: str, truth_n: int) -> None: assert count_word(letter_map, letter_coords) == truth_n -XMAS_SAMPLE = dedent( - """\ +XMAS_SAMPLE = dedent("""\ .M.S...... ..A..MSMS. .M.S.MAA.. @@ -85,8 +78,7 @@ def test_count_xmas(raw_puzzle: str, truth_n: int) -> None: .A.A.A.A.. M.M.M.M.M. .......... - """ -) + """) def test_count_x_mas() -> None: diff --git a/2024/Day_05/test_day05.py b/2024/Day_05/test_day05.py index 0e5d45f..a5039e8 100644 --- a/2024/Day_05/test_day05.py +++ b/2024/Day_05/test_day05.py @@ -12,15 +12,13 @@ reorder_spec, ) -PARSING_SAMPLE = dedent( - """\ +PARSING_SAMPLE = dedent("""\ 47|53 97|13 75,47,61,53,29 75,29,13 - """ -) + """) TRUTH_RULES = [PageOrderRule(47, 53), PageOrderRule(97, 13)] TRUTH_UPDATE_SPEC = [[75, 47, 61, 53, 29], [75, 29, 13]] @@ -54,8 +52,7 @@ def test_compile_order_rules() -> None: assert compile_order_rules(order_rules, reversed=True) == truth_reverse_compiled -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 47|53 97|13 97|61 @@ -84,8 +81,7 @@ def test_compile_order_rules() -> None: 75,97,47,61,53 61,13,29 97,13,75,29,47 - """ -) + """) SAMPLE_ORDERING_RULES, _ = parse_print_spec(SAMPLE_INPUT) SAMPLE_COMPILED_RULES = compile_order_rules(SAMPLE_ORDERING_RULES) diff --git a/2024/Day_06/test_day06.py b/2024/Day_06/test_day06.py index c98f1dc..3593a4a 100644 --- a/2024/Day_06/test_day06.py +++ b/2024/Day_06/test_day06.py @@ -3,8 +3,7 @@ from helpers.geometry import BoundingBox from .aoc_2024_day06 import parse_lab_map, trap_guard, walk_patrol -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ....#..... .........# .......... @@ -15,8 +14,7 @@ ........#. #......... ......#... - """ -) + """) TRUTH_START_LOC = (4, 6) TRUTH_OBSTRUCTIONS = {(4, 0), (9, 1), (2, 3), (7, 4), (1, 6), (8, 7), (0, 8), (6, 9)} TRUTH_BBOX = BoundingBox(((0, 0), (0, 9), (9, 0), (9, 9))) diff --git a/2024/Day_07/test_day07.py b/2024/Day_07/test_day07.py index 7d0ef6b..84e64f1 100644 --- a/2024/Day_07/test_day07.py +++ b/2024/Day_07/test_day07.py @@ -4,8 +4,7 @@ from .aoc_2024_day07 import calculate_calibration_result, can_solve, parse_calibration_equations -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 190: 10 19 3267: 81 40 27 83: 17 5 @@ -15,8 +14,7 @@ 192: 17 8 14 21037: 9 7 18 13 292: 11 6 16 20 - """ -) + """) TRUTH_PARSED = [ (190, [10, 19]), diff --git a/2024/Day_08/test_day08.py b/2024/Day_08/test_day08.py index de42614..7ab72c3 100644 --- a/2024/Day_08/test_day08.py +++ b/2024/Day_08/test_day08.py @@ -3,8 +3,7 @@ from helpers.geometry import BoundingBox, COORD from .aoc_2024_day08 import find_antinodes, parse_antenna_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ............ ........0... .....0...... @@ -17,8 +16,7 @@ .........A.. ............ ............ - """ -) + """) TRUTH_ANTENNAS = { "0": {(4, 4), (5, 2), (7, 3), (8, 1)}, diff --git a/2024/Day_10/test_day10.py b/2024/Day_10/test_day10.py index 11718f5..c288549 100644 --- a/2024/Day_10/test_day10.py +++ b/2024/Day_10/test_day10.py @@ -4,17 +4,14 @@ from .aoc_2024_day10 import find_all_trails, find_good_trails, parse_topo_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 0123 1234 8765 9876 - """ -) + """) -LARGER_SAMPLE_INPUT = dedent( - """\ +LARGER_SAMPLE_INPUT = dedent("""\ 89010123 78121874 87430965 @@ -23,8 +20,7 @@ 32019012 01329801 10456732 - """ -) + """) TRAILHEAD_TEST_CASES = ( (SAMPLE_INPUT, 1), diff --git a/2024/Day_12/test_day12.py b/2024/Day_12/test_day12.py index 71a6268..00c0e25 100644 --- a/2024/Day_12/test_day12.py +++ b/2024/Day_12/test_day12.py @@ -5,27 +5,22 @@ from .aoc_2024_day12 import build_plant_graph, calculate_bulk_fence_cost, calculate_fence_cost -SAMPLE_INPUT_1 = dedent( - """\ +SAMPLE_INPUT_1 = dedent("""\ AAAA BBCD BBCC EEEC - """ -) + """) -SAMPLE_INPUT_2 = dedent( - """\ +SAMPLE_INPUT_2 = dedent("""\ OOOOO OXOXO OOOOO OXOXO OOOOO - """ -) + """) -SAMPLE_INPUT_3 = dedent( - """\ +SAMPLE_INPUT_3 = dedent("""\ RRRRIICCFF RRRRIICCCF VVRRRCCFFF @@ -36,8 +31,7 @@ MIIIIIJJEE MIIISIJEEE MMMISSJEEE - """ -) + """) REGION_TEST_CASES = ( (SAMPLE_INPUT_1, 5), @@ -67,26 +61,22 @@ def test_calculate_fence_cost(plant_map: str, truth_fence_cost: int) -> None: assert calculate_fence_cost(pg) == truth_fence_cost -SAMPLE_INPUT_4 = dedent( - """\ +SAMPLE_INPUT_4 = dedent("""\ EEEEE EXXXX EEEEE EXXXX EEEEE - """ -) + """) -SAMPLE_INPUT_5 = dedent( - """\ +SAMPLE_INPUT_5 = dedent("""\ AAAAAA AAABBA AAABBA ABBAAA ABBAAA AAAAAA - """ -) + """) FENCE_BULK_COST_TEST_CASES = ( (SAMPLE_INPUT_1, 80), diff --git a/2024/Day_13/test_day13.py b/2024/Day_13/test_day13.py index 90e9a5d..9a0bcd6 100644 --- a/2024/Day_13/test_day13.py +++ b/2024/Day_13/test_day13.py @@ -4,8 +4,7 @@ from .aoc_2024_day13 import Button, ClawMachine, Prize, parse_machine_spec -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Button A: X+94, Y+34 Button B: X+22, Y+67 Prize: X=8400, Y=5400 @@ -21,18 +20,15 @@ Button A: X+69, Y+23 Button B: X+27, Y+71 Prize: X=18641, Y=10279 - """ -) + """) def test_machine_parse() -> None: - raw_spec = dedent( - """\ + raw_spec = dedent("""\ Button A: X+94, Y+34 Button B: X+22, Y+67 Prize: X=8400, Y=5400 - """ - ) + """) truth_machine = ClawMachine(a=Button(94, 34), b=Button(22, 67), prize=Prize(8400, 5400)) diff --git a/2024/Day_14/test_day14.py b/2024/Day_14/test_day14.py index 46c8b29..9197a49 100644 --- a/2024/Day_14/test_day14.py +++ b/2024/Day_14/test_day14.py @@ -4,13 +4,11 @@ from .aoc_2024_day14 import Robot, RobotGrid -SAMPLE_ROBOTS = dedent( - """\ +SAMPLE_ROBOTS = dedent("""\ p=0,4 v=3,-3 p=6,3 v=-1,-3 p=10,3 v=-1,2 - """ -) + """) TRUTH_ROBOTS = [ Robot(position=(0, 4), velocity=(3, -3)), Robot(position=(6, 3), velocity=(-1, -3)), @@ -23,8 +21,7 @@ def test_robot_parse() -> None: assert parsed_bots == TRUTH_ROBOTS -SAMPLE_GRID_ROBOTS = dedent( - """\ +SAMPLE_GRID_ROBOTS = dedent("""\ p=0,4 v=3,-3 p=6,3 v=-1,-3 p=10,3 v=-1,2 @@ -37,19 +34,16 @@ def test_robot_parse() -> None: p=7,3 v=-1,2 p=2,4 v=2,-3 p=9,5 v=-3,-3 - """ -) + """) -TRUTH_RENDERED = dedent( - """\ +TRUTH_RENDERED = dedent("""\ 1.12....... ........... ........... ......11.11 1.1........ .........1. - .......1...""" -) + .......1...""") def test_grid_render() -> None: @@ -61,81 +55,69 @@ def test_grid_render() -> None: STEP_CASES = ( ( - dedent( - """\ + dedent("""\ ........... ........... ........... ........... ..1........ ........... - ...........""" - ), + ..........."""), 0, ), ( - dedent( - """\ + dedent("""\ ........... ....1...... ........... ........... ........... ........... - ...........""" - ), + ..........."""), 1, ), ( - dedent( - """\ + dedent("""\ ........... ........... ........... ........... ........... ......1.... - ...........""" - ), + ..........."""), 2, ), ( - dedent( - """\ + dedent("""\ ........... ........... ........1.. ........... ........... ........... - ...........""" - ), + ..........."""), 3, ), ( - dedent( - """\ + dedent("""\ ........... ........... ........... ........... ........... ........... - ..........1""" - ), + ..........1"""), 4, ), ( - dedent( - """\ + dedent("""\ ........... ........... ........... .1......... ........... ........... - ...........""" - ), + ..........."""), 5, ), ) @@ -154,16 +136,14 @@ def test_full_sim() -> None: parsed_bots = [Robot.from_raw(ln) for ln in SAMPLE_GRID_ROBOTS.splitlines()] grid = RobotGrid(width=11, height=7, robots=parsed_bots) - TRUTH_SIM_RENDERED = dedent( - """\ + TRUTH_SIM_RENDERED = dedent("""\ ......2..1. ........... 1.......... .11........ .....1..... ...12...... - .1....1....""" - ) + .1....1....""") grid.step(100) assert grid.render_grid() == TRUTH_SIM_RENDERED diff --git a/2024/Day_15/test_day15.py b/2024/Day_15/test_day15.py index 3c1aef4..001b8a2 100644 --- a/2024/Day_15/test_day15.py +++ b/2024/Day_15/test_day15.py @@ -5,14 +5,12 @@ from helpers.geometry import MoveDir from .aoc_2024_day15 import Warehouse, parse_instructions, parse_warehouse_map -SAMPLE_MAP = dedent( - """\ +SAMPLE_MAP = dedent("""\ #### #.O# ##@# #### - """ -) + """) # fmt: off TRUTH_WALLS = {(0, 1), (1, 2), (0, 0), (3, 1), (0, 3), (2, 0), (3, 0), (2, 3), (0, 2), (3, 3), (1, 0), (3, 2), (1, 3)} # noqa: E501 @@ -38,8 +36,7 @@ def test_parse_instructions() -> None: assert instructions == TRUTH_INSTRUCTIONS -SHORT_EXAMPLE = dedent( - """\ +SHORT_EXAMPLE = dedent("""\ ######## #..O.O.# ##@.O..# @@ -50,11 +47,9 @@ def test_parse_instructions() -> None: ######## <^^>>>vv>v<< - """ -) + """) -LONG_EXAMPLE = dedent( - """\ +LONG_EXAMPLE = dedent("""\ ########## #..O..O.O# #......O.# @@ -76,14 +71,12 @@ def test_parse_instructions() -> None: <><^^>^^^<>^vv<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<> ^^>vv<^v^v^<>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<>< v^^>>><<^^<>>^v^v^<<>^<^v^v><^<<<><<^vv>>v>v^<<^ - """ -) + """) RENDERING_TEST_CASES = ( ( SHORT_EXAMPLE, - dedent( - """\ + dedent("""\ ######## #..O.O.# ##@.O..# @@ -91,13 +84,11 @@ def test_parse_instructions() -> None: #.#.O..# #...O..# #......# - ########""" - ), + ########"""), ), ( LONG_EXAMPLE, - dedent( - """\ + dedent("""\ ########## #..O..O.O# #......O.# @@ -107,8 +98,7 @@ def test_parse_instructions() -> None: #O..O..O.# #.OO.O.OO# #....O...# - ##########""" - ), + ##########"""), ), ) @@ -123,8 +113,7 @@ def test_warehouse_render(raw_doc: str, truth_rendered: str) -> None: EXECUTION_TEST_CASES = ( ( SHORT_EXAMPLE, - dedent( - """\ + dedent("""\ ######## #....OO# ##.....# @@ -132,13 +121,11 @@ def test_warehouse_render(raw_doc: str, truth_rendered: str) -> None: #.#O@..# #...O..# #...O..# - ########""" - ), + ########"""), ), ( LONG_EXAMPLE, - dedent( - """\ + dedent("""\ ########## #.O.O.OOO# #........# @@ -148,8 +135,7 @@ def test_warehouse_render(raw_doc: str, truth_rendered: str) -> None: #O.....OO# #O.....OO# #OO....OO# - ##########""" - ), + ##########"""), ), ) diff --git a/2024/Day_16/test_day16.py b/2024/Day_16/test_day16.py index 7530f7a..7f88a96 100644 --- a/2024/Day_16/test_day16.py +++ b/2024/Day_16/test_day16.py @@ -4,8 +4,7 @@ from .aoc_2024_day16 import calculate_lowest_score, n_seat_locations, parse_reindeer_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ############### #.......#....E# #.#.###.#.###.# @@ -21,11 +20,9 @@ #.###.#.#.#.#.# #S..#.....#...# ############### - """ -) + """) -ANOTHER_SAMPLE_INPUT = dedent( - """\ +ANOTHER_SAMPLE_INPUT = dedent("""\ ################# #...#...#...#..E# #.#.#.#.#.#.#.#.# @@ -43,8 +40,7 @@ #.#.#.#########.# #S#.............# ################# - """ -) + """) LOW_SCORE_TEST_CASES = ( (SAMPLE_INPUT, 7036), diff --git a/2024/Day_17/test_day17.py b/2024/Day_17/test_day17.py index 25cb633..77965a6 100644 --- a/2024/Day_17/test_day17.py +++ b/2024/Day_17/test_day17.py @@ -2,15 +2,13 @@ from .aoc_2024_day17 import ChronoComp -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ Register A: 729 Register B: 0 Register C: 0 Program: 0,1,5,4,3,0 - """ -) + """) TRUTH_STDOUT = "4,6,3,5,6,3,5,2,1,0" diff --git a/2024/Day_18/test_day18.py b/2024/Day_18/test_day18.py index 2fc1b6f..7f68183 100644 --- a/2024/Day_18/test_day18.py +++ b/2024/Day_18/test_day18.py @@ -2,8 +2,7 @@ from .aoc_2024_day18 import build_grid, find_first_blocker, parse_byte_positions, shortest_path -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ 5,4 4,2 4,5 @@ -29,8 +28,7 @@ 0,5 1,6 2,0 - """ -) + """) def test_shortest_path_len() -> None: diff --git a/2024/Day_19/test_day19.py b/2024/Day_19/test_day19.py index 425aeb8..6223dd5 100644 --- a/2024/Day_19/test_day19.py +++ b/2024/Day_19/test_day19.py @@ -23,8 +23,7 @@ def test_is_possible(pattern: str, truth_is_possible: bool) -> None: assert is_possible(TOWELS, pattern) == truth_is_possible -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ r, wr, b, g, bwu, rb, gb, br brwrr @@ -35,8 +34,7 @@ def test_is_possible(pattern: str, truth_is_possible: bool) -> None: bwurrg brgr bbrgwb - """ -) + """) def test_n_possible() -> None: diff --git a/2024/Day_20/test_day20.py b/2024/Day_20/test_day20.py index 171708f..19047f8 100644 --- a/2024/Day_20/test_day20.py +++ b/2024/Day_20/test_day20.py @@ -1,7 +1,6 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ############### #...#...#.....# #.#.#.#.#.###.# @@ -17,5 +16,4 @@ #.#.#.#.#.#.### #...#...#...### ############### - """ -) + """) diff --git a/2024/Day_21/test_day21.py b/2024/Day_21/test_day21.py index 3199c79..1aa1a71 100644 --- a/2024/Day_21/test_day21.py +++ b/2024/Day_21/test_day21.py @@ -1,6 +1,4 @@ from textwrap import dedent -SAMPLE_INPUT = dedent( - """\ - """ -) +SAMPLE_INPUT = dedent("""\ + """) diff --git a/2024/Day_23/test_day23.py b/2024/Day_23/test_day23.py index ac02bda..91b86b0 100644 --- a/2024/Day_23/test_day23.py +++ b/2024/Day_23/test_day23.py @@ -2,8 +2,7 @@ from .aoc_2024_day23 import find_n_length_connections, find_password, find_t_cliques, parse_lan_map -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ kh-tc qp-kh de-cg @@ -36,8 +35,7 @@ wh-qp tb-vc td-yn - """ -) + """) def test_3_cliques() -> None: diff --git a/2024/Day_24/test_day24.py b/2024/Day_24/test_day24.py index 8a4afac..8eaefcc 100644 --- a/2024/Day_24/test_day24.py +++ b/2024/Day_24/test_day24.py @@ -4,8 +4,7 @@ from .aoc_2024_day24 import Wiring, parse_schematic, run_circuit, wire_and, wire_or, wire_xor -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ x00: 1 x01: 1 x02: 1 @@ -16,11 +15,9 @@ x00 AND y00 -> z00 x01 XOR y01 -> z01 x02 OR y02 -> z02 - """ -) + """) -LONGER_SAMPLE_INPUT = dedent( - """\ +LONGER_SAMPLE_INPUT = dedent("""\ x00: 1 x01: 0 x02: 1 @@ -68,8 +65,7 @@ hwm AND bqk -> z03 tgd XOR rvg -> z12 tnw OR pbm -> gnj - """ -) + """) TRUTH_INITIAL_STATE = { "x00": 1, diff --git a/2024/Day_25/test_day25.py b/2024/Day_25/test_day25.py index fdfb9fe..ef9cca6 100644 --- a/2024/Day_25/test_day25.py +++ b/2024/Day_25/test_day25.py @@ -6,8 +6,7 @@ def test_parse_lock() -> None: - schematic = dedent( - """\ + schematic = dedent("""\ ##### .#### .#### @@ -15,14 +14,12 @@ def test_parse_lock() -> None: .#.#. .#... ..... - """ - ) + """) assert Lock.from_raw(schematic) == Lock((0, 5, 3, 4, 3)) def test_parse_key() -> None: - schematic = dedent( - """\ + schematic = dedent("""\ ..... #.... #.... @@ -30,13 +27,11 @@ def test_parse_key() -> None: #.#.# #.### ##### - """ - ) + """) assert Key.from_raw(schematic) == Key((5, 0, 2, 1, 3)) -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ ##### .#### .#### @@ -76,8 +71,7 @@ def test_parse_key() -> None: #.#.. #.#.# ##### - """ -) + """) TRUTH_LOCKS = [ Lock((0, 5, 3, 4, 3)), diff --git a/2025/Day_01/test_day01.py b/2025/Day_01/test_day01.py index af60614..496a435 100644 --- a/2025/Day_01/test_day01.py +++ b/2025/Day_01/test_day01.py @@ -32,8 +32,7 @@ def test_rotate_n(start: int, rotation: Rotation, truth_out: int) -> None: assert rotate_dial(start, rotation) == truth_out -SAMPLE_INPUT = dedent( - """\ +SAMPLE_INPUT = dedent("""\ L68 L30 R48 @@ -44,8 +43,7 @@ def test_rotate_n(start: int, rotation: Rotation, truth_out: int) -> None: L99 R14 L82 - """ -) + """) def test_find_password() -> None: