From 72b215ad869d0404cfdab382548fb2012db8e79f Mon Sep 17 00:00:00 2001 From: Roel Adriaans Date: Wed, 29 Jan 2025 08:43:47 +0100 Subject: [PATCH] Update styling --- src/adventofcode2024/day08.py | 24 ++++++++++++++++++ tests/adventofcode2024/test_day08_a.py | 24 ++++++++++++++++++ tests/adventofcode2024/test_day08_b.py | 25 +++++++++++++++++++ .../testdata/day_08/day08_test.txt | 12 +++++++++ 4 files changed, 85 insertions(+) create mode 100644 src/adventofcode2024/day08.py create mode 100644 tests/adventofcode2024/test_day08_a.py create mode 100644 tests/adventofcode2024/test_day08_b.py create mode 100644 tests/adventofcode2024/testdata/day_08/day08_test.txt diff --git a/src/adventofcode2024/day08.py b/src/adventofcode2024/day08.py new file mode 100644 index 0000000..7bb88a0 --- /dev/null +++ b/src/adventofcode2024/day08.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +from collections import defaultdict + +from adventofcode.utils.abstract import FileReaderSolution + + +class Day08: + pass + + +class Day08PartA(Day08, FileReaderSolution): + def solve(self, input_data: str) -> int: + antennas: defaultdict[str, list[tuple[int, int]]] = defaultdict(list) + for i, row in enumerate(input_data.splitlines()): + for j, val in enumerate(row): + if val != ".": + antennas[val].append((i, j)) + return -1 + + +class Day08PartB(Day08, FileReaderSolution): + def solve(self, input_data: str) -> int: + raise NotImplementedError diff --git a/tests/adventofcode2024/test_day08_a.py b/tests/adventofcode2024/test_day08_a.py new file mode 100644 index 0000000..93f340b --- /dev/null +++ b/tests/adventofcode2024/test_day08_a.py @@ -0,0 +1,24 @@ +import pytest + +from adventofcode2024.day08 import Day08PartA + + +class TestDay08PartA: + def test_day08a_testdata(self, testdata): + solution = Day08PartA() + result = solution.solve(testdata) + assert result == 14 + + @pytest.mark.xfail(reason="Not yet implemented", raises=NotImplementedError) + @pytest.mark.parametrize(("input_data", "expected_result"), [("", ""), ("", "")]) + def test_day08a_solve(self, input_data, expected_result): + solution = Day08PartA() + result = solution.solve(input_data) + assert result == expected_result + + @pytest.mark.xfail(reason="Not yet implemented", raises=NotImplementedError) + def test_day08a_data(self): + """Result we got when we did the real solution""" + solution = Day08PartA() + res = solution("day_08/day08.txt") + assert res == 0 diff --git a/tests/adventofcode2024/test_day08_b.py b/tests/adventofcode2024/test_day08_b.py new file mode 100644 index 0000000..a464004 --- /dev/null +++ b/tests/adventofcode2024/test_day08_b.py @@ -0,0 +1,25 @@ +import pytest + +from adventofcode2024.day08 import Day08PartB + + +class TestDay08PartB: + @pytest.mark.xfail(reason="Not yet implemented", raises=NotImplementedError) + def test_day08b_testdata(self, testdata): + solution = Day08PartB() + result = solution.solve(testdata) + assert result == 0 + + @pytest.mark.xfail(reason="Not yet implemented", raises=NotImplementedError) + @pytest.mark.parametrize(("input_data", "expected_result"), [("", ""), ("", "")]) + def test_day08b_solve(self, input_data, expected_result): + solution = Day08PartB() + result = solution.solve(input_data) + assert result == expected_result + + @pytest.mark.xfail(reason="Not yet implemented", raises=NotImplementedError) + def test_day08b_data(self): + """Result we got when we did the real solution""" + solution = Day08PartB() + res = solution("day_08/day08.txt") + assert res == 0 diff --git a/tests/adventofcode2024/testdata/day_08/day08_test.txt b/tests/adventofcode2024/testdata/day_08/day08_test.txt new file mode 100644 index 0000000..78a1e91 --- /dev/null +++ b/tests/adventofcode2024/testdata/day_08/day08_test.txt @@ -0,0 +1,12 @@ +............ +........0... +.....0...... +.......0.... +....0....... +......A..... +............ +............ +........A... +.........A.. +............ +............