Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelblijleven committed Dec 4, 2023
1 parent d93be98 commit f6a83e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/adventofcode/year_2023/day_03_2023.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def neighbour_has_adjacent_symbol(current_position: tuple[int, int], symbols: se


def neighbouring_gear_coords(
current_position: tuple[int, int], gears: Iterable[tuple[int, int]]
current_position: tuple[int, int], gears: Iterable[tuple[int, int]]
) -> tuple[int, int] | None:
x, y = current_position
for y_mod in [-1, 0, 1]:
Expand Down Expand Up @@ -90,7 +90,7 @@ def find_gear_ratios(lines: list[str]) -> int:
gears[gear_pos].append(int(match.group()))

if len(gears[gear_pos]) == 2:
total += (gears[gear_pos][0] * gears[gear_pos][1])
total += gears[gear_pos][0] * gears[gear_pos][1]
break

return total
Expand Down
48 changes: 30 additions & 18 deletions tests/adventofcode/year_2023/test_day_03_2023.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import pytest

from adventofcode.year_2023.day_03_2023 import (part_two, part_one, find_symbol_coords, find_gear_coords,
neighbour_has_adjacent_symbol, neighbouring_gear_coords)
from adventofcode.year_2023.day_03_2023 import (
find_gear_coords,
find_symbol_coords,
neighbour_has_adjacent_symbol,
neighbouring_gear_coords,
part_one,
part_two,
)

test_input = [
"467..114..",
Expand All @@ -25,27 +31,33 @@ def test_find_gear_coords():
assert find_gear_coords(test_input) == {(3, 1): [], (3, 4): [], (5, 8): []}


@pytest.mark.parametrize(["current_position", "expected"], [
((0,0), True),
((0,1), True),
((1,1), True),
((1,0), True),
((2,2), True),
((3,3), False),
])
@pytest.mark.parametrize(
["current_position", "expected"],
[
((0, 0), True),
((0, 1), True),
((1, 1), True),
((1, 0), True),
((2, 2), True),
((3, 3), False),
],
)
def test_neighbour_has_adjacent_symbol(current_position, expected):
symbols = {(1, 1)}
assert neighbour_has_adjacent_symbol(current_position, symbols) == expected


@pytest.mark.parametrize(["current_position", "expected"], [
((0,0), (1, 1)),
((0,1), (1, 1)),
((1,1), (1, 1)),
((1,0), (1, 1)),
((2,2), (1, 1)),
((3,3), None),
])
@pytest.mark.parametrize(
["current_position", "expected"],
[
((0, 0), (1, 1)),
((0, 1), (1, 1)),
((1, 1), (1, 1)),
((1, 0), (1, 1)),
((2, 2), (1, 1)),
((3, 3), None),
],
)
def test_neighbouring_gear_coords(current_position, expected):
gears = {(1, 1)}
assert neighbouring_gear_coords(current_position, gears) == expected
Expand Down

0 comments on commit f6a83e8

Please sign in to comment.