Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions 2015/Day_07/test_day7.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from aoc_2015_day7 import CircuitDiagram

PART_ONE = {
"input": dedent(
"""\
"input": dedent("""\
123 -> x
456 -> y
x AND y -> d
Expand All @@ -14,8 +13,7 @@
y RSHIFT 2 -> g
NOT x -> h
NOT y -> i
"""
),
"""),
"output": [
("d", 72),
("e", 507),
Expand Down
6 changes: 2 additions & 4 deletions 2015/Day_08/test_day8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 2 additions & 4 deletions 2015/Day_14/test_day14.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 2 additions & 4 deletions 2015/Day_16/aoc_2015_day16.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from pathlib import Path
from textwrap import dedent

GIFT_CLUE = dedent(
"""\
GIFT_CLUE = dedent("""\
children: 3
cats: 7
samoyeds: 2
Expand All @@ -15,8 +14,7 @@
trees: 3
cars: 2
perfumes: 1
"""
).splitlines()
""").splitlines()


def parse_gift_clue(clue_input: list[str]) -> dict[str, int]:
Expand Down
30 changes: 10 additions & 20 deletions 2015/Day_18/test_day_18.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,44 @@
from textwrap import dedent

SAMPLE_STEPS = [
dedent(
"""\
dedent("""\
.#.#.#
...##.
#....#
..#...
#.#..#
####..
"""
),
dedent(
"""\
"""),
dedent("""\
..##..
..##.#
...##.
......
#.....
#.##..
"""
),
dedent(
"""\
"""),
dedent("""\
..###.
......
..###.
......
.#....
.#....
"""
),
dedent(
"""\
"""),
dedent("""\
...#..
......
...#..
..##..
......
......
"""
),
dedent(
"""\
"""),
dedent("""\
......
......
..##..
..##..
......
......
"""
),
"""),
]
18 changes: 6 additions & 12 deletions 2015/Day_19/test_day_19.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
]
Expand Down
14 changes: 5 additions & 9 deletions 2016/Day_02/aoc_2016_day02.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions 2016/Day_02/test_day02.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
6 changes: 2 additions & 4 deletions 2016/Day_03/test_day03.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions 2016/Day_04/test_day04.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions 2016/Day_06/test_day06.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from .aoc_2016_day06 import correct_message

SAMPLE_INPUT = dedent(
"""\
SAMPLE_INPUT = dedent("""\
eedadn
drvtee
eandsr
Expand All @@ -20,8 +19,7 @@
vrdear
dvrsen
enarar
"""
)
""")


def test_error_correction() -> None:
Expand Down
12 changes: 4 additions & 8 deletions 2016/Day_08/test_day08.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@

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:
instructions = parse_instructions(SAMPLE_INPUT)
assert calculate_lit_pixels(instructions) == 6


TRUTH_END_STATE = dedent(
"""\
TRUTH_END_STATE = dedent("""\
.#..#.#
#.#....
.#....."""
)
.#.....""")


def test_screen_state() -> None:
Expand Down
6 changes: 2 additions & 4 deletions 2016/Day_10/test_day10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 4 additions & 8 deletions 2017/Day_02/test_day02.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

PART_ONE_CASES = (
(
dedent(
"""\
dedent("""\
5 1 9 5
7 5 3
2 4 6 8
"""
).splitlines(),
""").splitlines(),
18,
),
)
Expand All @@ -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,
),
)
Expand Down
Loading