cleaned up templates.

This commit is contained in:
gabe 2022-08-18 21:42:55 -05:00
parent 7fd7d753bb
commit fdbc386511
6 changed files with 68 additions and 4 deletions

View file

@ -10,4 +10,4 @@ pytest = "*"
[dev-packages] [dev-packages]
[requires] [requires]
python_version = "3.9" python_version = "3"

4
Pipfile.lock generated
View file

@ -1,11 +1,11 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "0f2e2e1eec7667a0a76ab90193491e106610a921be445eef118b5d170f2d175e" "sha256": "bf24791e041f80c18b2c667226aa3b47e25ebb5779ca595d076d8cf87f785918"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
"python_version": "3.9" "python_version": "3"
}, },
"sources": [ "sources": [
{ {

30
day1/day1.py Executable file
View file

@ -0,0 +1,30 @@
#! /usr/bin/env python3
import pathlib
import sys
# import parse
def parse(puzzle_input):
"""Parse input"""
def part1(data):
"""Solve part 1"""
def part2(data):
"""Solve part 2"""
def solve(puzzle_input):
"""Solve the puzzle for the given input"""
data = parse(puzzle_input)
solution1 = part1(data)
solution2 = part2(data)
return solution1, solution2
if __name__ == "__main__":
for path in sys.argv[1:]:
print(f"{path}:")
puzzle_input = pathlib.Path(path).read_text().strip()
print(f'{puzzle_input}')
solutions = solve(puzzle_input)
print("\n".join(str(solution) for solution in solutions))

33
day1/test_day1.py Normal file
View file

@ -0,0 +1,33 @@
#! /usr/bin/env python3
import pathlib
import pytest
import template as aoc
PUZZLE_DIR = pathlib.Path(__file__).parent
#these test fixtures setup the test, mainly by reading the filename into a string in this simple case.
@pytest.fixture
def example1():
puzzle_input = (PUZZLE_DIR / "example1").read_text().strip()
return aoc.parse(puzzle_input)
@pytest.fixture
def example2():
puzzle_input = (PUZZLE_DIR / "example2").read_text().strip()
return aoc.parse(puzzle_input)
@pytest.mark.skip(reason="Not implemented")
def test_parse_example1(example1):
"""Test that input is parsed properly"""
assert example1 == ...
@pytest.mark.skip(reason="Not implemented")
def test_part1_example1(example1):
"""Test part 1 on example input"""
assert aoc.part1(example1) == ...
@pytest.mark.skip(reason="Not implemented")
def test_part2_example2(example2):
"""Test part 2 on example input"""
assert aoc.part2(example2) == ...

View file

@ -1,4 +1,4 @@
# aoc_template.py #! /usr/bin/env python3
import pathlib import pathlib
import sys import sys

View file

@ -1,3 +1,4 @@
#! /usr/bin/env python3
import pathlib import pathlib
import pytest import pytest