Skip to content

Commit ee3d5d0

Browse files
authored
Merge pull request #152 from GriceTurrble/feat/day3-and-justfiles
feat: day3 scaffold; justfiles added
2 parents 29c3be6 + 0418752 commit ee3d5d0

File tree

10 files changed

+77
-1
lines changed

10 files changed

+77
-1
lines changed

2024/Justfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Root justfile for AoC 2024
2+
3+
mod py 'python/py.just'
4+
5+
6+
# Show these help docs
7+
help:
8+
@just --list --unsorted --justfile {{ source_file() }}

2024/python/py.just

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# justfile recipes specific to the Python project in AoC 2024
2+
3+
# Show these help docs
4+
help:
5+
@just --list --unsorted --justfile {{ source_file() }}
6+
7+
# Generate files for a new day
8+
new-day DAY:
9+
uv run cli create-day {{DAY}}

2024/python/pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build-backend = "hatchling.build"
2525
cli = "grice_py_aoc_2024.cli:cli"
2626
day01 = "grice_py_aoc_2024.day01.main:main"
2727
day02 = "grice_py_aoc_2024.day02.main:main"
28+
day03 = "grice_py_aoc_2024.day03.main:main"
2829

2930
[tool.pytest.ini_options]
3031
addopts = "--verbose"

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

Whitespace-only changes.

2024/python/src/grice_py_aoc_2024/day03/inputs.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from __future__ import annotations
2+
3+
import time
4+
import typing
5+
from pathlib import Path
6+
7+
if typing.TYPE_CHECKING:
8+
from io import TextIOWrapper
9+
10+
FILE = Path(__file__).parent / "inputs.txt"
11+
12+
13+
def part1(inputs: TextIOWrapper):
14+
return "Not done yet!"
15+
16+
17+
def part2(inputs: TextIOWrapper):
18+
return "Not done yet!"
19+
20+
21+
def main():
22+
_start1 = time.perf_counter()
23+
with open(FILE) as f:
24+
result1 = part1(f)
25+
_delta1 = time.perf_counter() - _start1
26+
print(f">> Part 1: {result1} ({_delta1:.6f}s)")
27+
28+
_start2 = time.perf_counter()
29+
with open(FILE) as f:
30+
result2 = part2(f)
31+
_delta2 = time.perf_counter() - _start2
32+
print(f">> Part 2: {result2} ({_delta2:.6f}s)")
33+
34+
35+
if __name__ == "__main__":
36+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
from .main import part1, part2
6+
7+
TEST_FILE = Path(__file__).parent / "test_inputs.txt"
8+
RESULT_PART_1 = "Now it's done!"
9+
RESULT_PART_2 = "Now it's done!"
10+
11+
12+
def test_part1():
13+
with open(TEST_FILE) as f:
14+
result = part1(f)
15+
assert result == RESULT_PART_1
16+
17+
18+
def test_part2():
19+
with open(TEST_FILE) as f:
20+
result = part2(f)
21+
assert result == RESULT_PART_2

2024/python/src/grice_py_aoc_2024/day03/test_inputs.txt

Whitespace-only changes.

2024/python/src/grice_py_aoc_2024/templates/main.py-tpl

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ FILE = Path(__file__).parent / "inputs.txt"
1313
def part1(inputs: TextIOWrapper):
1414
return "Not done yet!"
1515

16+
1617
def part2(inputs: TextIOWrapper):
1718
return "Not done yet!"
1819

2024/python/src/grice_py_aoc_2024/templates/test_day.py-tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from .main import part1, part2
66

77
TEST_FILE = Path(__file__).parent / "test_inputs.txt"
88
RESULT_PART_1 = "Now it's done!"
9-
RESULT_PART_2 = "Not done yet!"
9+
RESULT_PART_2 = "Now it's done!"
1010

1111

1212
def test_part1():

0 commit comments

Comments
 (0)