Skip to content

Commit

Permalink
Merge pull request #152 from GriceTurrble/feat/day3-and-justfiles
Browse files Browse the repository at this point in the history
feat: day3 scaffold; justfiles added
  • Loading branch information
GriceTurrble authored Dec 2, 2024
2 parents 29c3be6 + 0418752 commit ee3d5d0
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 1 deletion.
8 changes: 8 additions & 0 deletions 2024/Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Root justfile for AoC 2024

mod py 'python/py.just'


# Show these help docs
help:
@just --list --unsorted --justfile {{ source_file() }}
9 changes: 9 additions & 0 deletions 2024/python/py.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# justfile recipes specific to the Python project in AoC 2024

# Show these help docs
help:
@just --list --unsorted --justfile {{ source_file() }}

# Generate files for a new day
new-day DAY:
uv run cli create-day {{DAY}}
1 change: 1 addition & 0 deletions 2024/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ build-backend = "hatchling.build"
cli = "grice_py_aoc_2024.cli:cli"
day01 = "grice_py_aoc_2024.day01.main:main"
day02 = "grice_py_aoc_2024.day02.main:main"
day03 = "grice_py_aoc_2024.day03.main:main"

[tool.pytest.ini_options]
addopts = "--verbose"
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions 2024/python/src/grice_py_aoc_2024/day03/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import annotations

import time
import typing
from pathlib import Path

if typing.TYPE_CHECKING:
from io import TextIOWrapper

FILE = Path(__file__).parent / "inputs.txt"


def part1(inputs: TextIOWrapper):
return "Not done yet!"


def part2(inputs: TextIOWrapper):
return "Not done yet!"


def main():
_start1 = time.perf_counter()
with open(FILE) as f:
result1 = part1(f)
_delta1 = time.perf_counter() - _start1
print(f">> Part 1: {result1} ({_delta1:.6f}s)")

_start2 = time.perf_counter()
with open(FILE) as f:
result2 = part2(f)
_delta2 = time.perf_counter() - _start2
print(f">> Part 2: {result2} ({_delta2:.6f}s)")


if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions 2024/python/src/grice_py_aoc_2024/day03/test_day03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import annotations

from pathlib import Path

from .main import part1, part2

TEST_FILE = Path(__file__).parent / "test_inputs.txt"
RESULT_PART_1 = "Now it's done!"
RESULT_PART_2 = "Now it's done!"


def test_part1():
with open(TEST_FILE) as f:
result = part1(f)
assert result == RESULT_PART_1


def test_part2():
with open(TEST_FILE) as f:
result = part2(f)
assert result == RESULT_PART_2
Empty file.
1 change: 1 addition & 0 deletions 2024/python/src/grice_py_aoc_2024/templates/main.py-tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ FILE = Path(__file__).parent / "inputs.txt"
def part1(inputs: TextIOWrapper):
return "Not done yet!"


def part2(inputs: TextIOWrapper):
return "Not done yet!"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from .main import part1, part2

TEST_FILE = Path(__file__).parent / "test_inputs.txt"
RESULT_PART_1 = "Now it's done!"
RESULT_PART_2 = "Not done yet!"
RESULT_PART_2 = "Now it's done!"


def test_part1():
Expand Down

0 comments on commit ee3d5d0

Please sign in to comment.