Skip to content

Commit 9120baa

Browse files
committed
Advent of Code: improve parser-guesser and apply to another 22 solutions
1 parent 0b46ec8 commit 9120baa

26 files changed

Lines changed: 56 additions & 46 deletions

File tree

advent_of_code/2015/d02.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Day02(aoc.Challenge):
1919
aoc.TestCase(inputs=SAMPLE[0], part=2, want=34),
2020
aoc.TestCase(inputs=SAMPLE[1], part=2, want=14),
2121
]
22-
INPUT_PARSER = aoc.parse_ints
2322

2423
def part1(self, puzzle_input: InputType) -> int:
2524
"""Return the amount of wrapping paper needed."""

advent_of_code/2015/d19.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class Day19(aoc.Challenge):
4848
aoc.TestCase(inputs=SAMPLE[0], part=2, want=aoc.TEST_SKIP),
4949
]
5050

51-
INPUT_PARSER = aoc.ParseBlocks([aoc.parse_multi_str_per_line, aoc.parse_one_str])
52-
5351
def part1(self, puzzle_input: InputType) -> int:
5452
mappings, start = puzzle_input
5553
found = set()

advent_of_code/2017/d20.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Day20(aoc.Challenge):
2424
aoc.TestCase(part=1, inputs=SAMPLE[0], want=0),
2525
aoc.TestCase(part=2, inputs=SAMPLE[1], want=1),
2626
]
27-
INPUT_PARSER = aoc.parse_ints
2827

2928
@staticmethod
3029
def distance(vals: tuple[int, ...]) -> int:

advent_of_code/2018/d06.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Day06(aoc.Challenge):
2020
aoc.TestCase(part=1, inputs=SAMPLE, want=17),
2121
aoc.TestCase(part=2, inputs=SAMPLE, want=16),
2222
]
23-
INPUT_PARSER = aoc.parse_ints
2423

2524
def minmax(self, puzzle_input: list[list[int]]) -> tuple[int, int, int, int]:
2625
"""Return the boundaries of the puzzle."""

advent_of_code/2018/d14.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
class Day14(aoc.Challenge):
88
"""Day 14: Chocolate Charts. Mix recipes until a pattern is found."""
99

10-
INPUT_PARSER = aoc.parse_one_str
1110
TESTS = [
1211
aoc.TestCase(inputs="9", part=1, want="5158916779"),
1312
aoc.TestCase(inputs="5", part=1, want="0124515891"),
@@ -18,6 +17,7 @@ class Day14(aoc.Challenge):
1817
aoc.TestCase(inputs="92510", part=2, want=18),
1918
aoc.TestCase(inputs="59414", part=2, want=2018),
2019
]
20+
INPUT_PARSER = aoc.parse_one_str
2121

2222
def solver(self, puzzle_input: str, part_one: bool) -> int | str:
2323
"""Solve for the target recipes."""

advent_of_code/2018/d18.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Day18(aoc.Challenge):
2727
aoc.TestCase(part=1, inputs=SAMPLE, want=1147),
2828
aoc.TestCase(part=2, inputs=SAMPLE, want=aoc.TEST_SKIP),
2929
]
30-
INPUT_PARSER = aoc.CoordinatesParserC(chars=None, origin_top_left=True)
30+
INPUT_PARSER = aoc.CoordinatesParserC()
3131

3232
def solver(self, puzzle_input: aoc.Map, part_one: bool) -> int:
3333
area = typing.cast(frozendict.frozendict[complex, str], frozendict.frozendict(puzzle_input.chars))

advent_of_code/2018/d19.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class Day19(aoc.Challenge):
2222
aoc.TestCase(part=1, inputs=SAMPLE, want=6),
2323
aoc.TestCase(part=2, inputs=SAMPLE, want=aoc.TEST_SKIP),
2424
]
25-
INPUT_PARSER = aoc.parse_multi_mixed_per_line
2625

2726
def compute(self, puzzle_input: list[list[str | int]], initial: int) -> int:
2827
"""Run a CPU simulator."""

advent_of_code/2018/d20.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Day20(aoc.Challenge):
1818
aoc.TestCase(part=1, inputs="^WSSEESWWWNW(S|NENNEEEENN(ESSSSW(NWSW|SSEN)|WSWWN(E|WWS(E|SS))))$", want=31),
1919
aoc.TestCase(part=2, inputs="", want=aoc.TEST_SKIP),
2020
]
21-
INPUT_PARSER = aoc.parse_one_str
2221

2322
def solver(self, puzzle_input: str, part_one: bool) -> int:
2423
"""Walk a regex to explore a map."""

advent_of_code/2018/d21.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class Day21(aoc.Challenge):
5858
aoc.TestCase(part=1, inputs="", want=aoc.TEST_SKIP),
5959
aoc.TestCase(part=2, inputs="", want=aoc.TEST_SKIP),
6060
]
61-
INPUT_PARSER = aoc.parse_multi_mixed_per_line
6261

6362
def part1(self, puzzle_input: list[list[str | int]]) -> int:
6463
"""Return the r0 value needed to make the program terminate."""

advent_of_code/2019/d02.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Day02(aoc.Challenge):
1616
aoc.TestCase(inputs=SAMPLE[0], part=1, want=3500),
1717
aoc.TestCase(inputs=SAMPLE[0], part=2, want=aoc.TEST_SKIP),
1818
]
19-
INPUT_PARSER = aoc.parse_one_str
2019

2120
def run_with_inputs(self, program: str, noun: int, verb: int) -> int:
2221
computer = intcode.Computer(program)

0 commit comments

Comments
 (0)