From fdbc386511484dc93df1eedab70f2303828776e1 Mon Sep 17 00:00:00 2001 From: gabe Date: Thu, 18 Aug 2022 21:42:55 -0500 Subject: [PATCH] cleaned up templates. --- Pipfile | 2 +- Pipfile.lock | 4 ++-- day1/day1.py | 30 ++++++++++++++++++++++++++++++ day1/test_day1.py | 33 +++++++++++++++++++++++++++++++++ template.py | 2 +- test_template.py | 1 + 6 files changed, 68 insertions(+), 4 deletions(-) create mode 100755 day1/day1.py create mode 100644 day1/test_day1.py diff --git a/Pipfile b/Pipfile index bf280c5..a30238f 100644 --- a/Pipfile +++ b/Pipfile @@ -10,4 +10,4 @@ pytest = "*" [dev-packages] [requires] -python_version = "3.9" +python_version = "3" diff --git a/Pipfile.lock b/Pipfile.lock index e995069..9431ae8 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "0f2e2e1eec7667a0a76ab90193491e106610a921be445eef118b5d170f2d175e" + "sha256": "bf24791e041f80c18b2c667226aa3b47e25ebb5779ca595d076d8cf87f785918" }, "pipfile-spec": 6, "requires": { - "python_version": "3.9" + "python_version": "3" }, "sources": [ { diff --git a/day1/day1.py b/day1/day1.py new file mode 100755 index 0000000..ae53008 --- /dev/null +++ b/day1/day1.py @@ -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)) diff --git a/day1/test_day1.py b/day1/test_day1.py new file mode 100644 index 0000000..d5a24ce --- /dev/null +++ b/day1/test_day1.py @@ -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) == ... diff --git a/template.py b/template.py index 88722df..39c0e07 100644 --- a/template.py +++ b/template.py @@ -1,4 +1,4 @@ -# aoc_template.py +#! /usr/bin/env python3 import pathlib import sys diff --git a/test_template.py b/test_template.py index b9d5749..d5a24ce 100644 --- a/test_template.py +++ b/test_template.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 import pathlib import pytest