Skip to content

Commit a0c75c0

Browse files
committed
feat: day 12 start (incomplete)
1 parent d988e02 commit a0c75c0

File tree

7 files changed

+216
-23
lines changed

7 files changed

+216
-23
lines changed

2024/inputs/day12.txt

+140
Large diffs are not rendered by default.

2024/inputs/tests/test_day12.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RRRRIICCFF
2+
RRRRIICCCF
3+
VVRRRCCFFF
4+
VVRCCCJFFF
5+
VVVVCJJCFE
6+
VVIVCCJJEE
7+
VVIIICJJEE
8+
MIIIIIJJEE
9+
MIIISIJEEE
10+
MMMISSJEEE

2024/python/pyproject.toml

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ version = "2024.12.1"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.13"
7-
dependencies = [
8-
"click>=8.1.7",
9-
"httpx>=0.28.1",
10-
"polars>=1.17.1",
11-
"toml>=0.10.2",
12-
]
7+
dependencies = [ "click>=8.1.7", "httpx>=0.28.1", "toml>=0.10.2",]
138
[[project.authors]]
149
name = "Galen Rice"
1510
1611

1712
[dependency-groups]
18-
dev = ["pytest>=8.3.4"]
13+
dev = [ "pytest>=8.3.4",]
1914

2015
[build-system]
21-
requires = ["hatchling"]
16+
requires = [ "hatchling",]
2217
build-backend = "hatchling.build"
2318

2419
[project.scripts]
@@ -34,6 +29,7 @@ day08 = "grice_py_aoc_2024.day08.main:main"
3429
day09 = "grice_py_aoc_2024.day09.main:main"
3530
day10 = "grice_py_aoc_2024.day10.main:main"
3631
day11 = "grice_py_aoc_2024.day11.main:main"
32+
day12 = "grice_py_aoc_2024.day12.main:main"
3733

3834
[tool.pytest.ini_options]
3935
addopts = "-ra -q"

2024/python/src/grice_py_aoc_2024/day12/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from __future__ import annotations
2+
3+
import time
4+
from pathlib import Path
5+
6+
DIR = Path(__file__).parent
7+
FILE = DIR.parents[3] / "inputs" / f"{DIR.stem}.txt"
8+
9+
10+
def part1(grid: list[str]) -> int:
11+
total = 0
12+
# TODO part 1
13+
return total
14+
15+
16+
def part2(grid: list[str]) -> int:
17+
total = 0
18+
# TODO part 2
19+
return total
20+
21+
22+
def main():
23+
grid = FILE.read_text().strip().split("\n")
24+
25+
_start1 = time.perf_counter()
26+
result1 = part1(grid=grid)
27+
_delta1 = time.perf_counter() - _start1
28+
print(f">> Part 1: {result1} ({_delta1:.6f}s)")
29+
30+
_start2 = time.perf_counter()
31+
result2 = part2(grid=grid)
32+
_delta2 = time.perf_counter() - _start2
33+
print(f">> Part 2: {result2} ({_delta2:.6f}s)")
34+
35+
36+
if __name__ == "__main__":
37+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
import pytest
6+
7+
from .main import part1, part2
8+
9+
DIR = Path(__file__).parent
10+
TEST_FILE = DIR.parents[3] / "inputs/tests" / f"test_{DIR.stem}.txt"
11+
EXPECTED_PART_1 = 1930
12+
EXPECTED_PART_2 = 456 # TODO replace!
13+
14+
15+
def test_part1():
16+
grid = TEST_FILE.read_text().strip().split("\n")
17+
result = part1(grid=grid)
18+
assert result == EXPECTED_PART_1
19+
20+
21+
@pytest.mark.xfail(reason=f"{DIR.stem} P1 incomplete")
22+
def test_part2():
23+
grid = TEST_FILE.read_text().strip().split("\n")
24+
result = part2(grid=grid)
25+
assert result == EXPECTED_PART_2

2024/python/uv.lock

-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)