mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Implement 2024 day 2
This commit is contained in:
6
2024/tests/samples/02.txt
Normal file
6
2024/tests/samples/02.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9
|
||||
26
2024/tests/test_day2.py
Normal file
26
2024/tests/test_day2.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
from aoc.days.day2 import DayRunner, is_savable
|
||||
|
||||
|
||||
def get_data() -> str:
|
||||
sample = os.path.dirname(__file__) + "/samples/02.txt"
|
||||
with open(sample, mode="rt", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def test_individual_samples() -> None:
|
||||
assert is_savable("7 6 4 2 1")
|
||||
assert not is_savable("1 2 7 8 9")
|
||||
assert not is_savable("9 7 6 2 1")
|
||||
assert is_savable("1 3 2 4 5")
|
||||
assert is_savable("8 6 4 4 1")
|
||||
assert is_savable("1 3 6 7 9")
|
||||
|
||||
|
||||
def test_sample_part1() -> None:
|
||||
assert DayRunner.part1(get_data()) == 2
|
||||
|
||||
|
||||
def test_sample_part2() -> None:
|
||||
assert DayRunner.part2(get_data()) == 4
|
||||
Reference in New Issue
Block a user