mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
2019 day 24 part 1
This commit is contained in:
64
2019/tests/test_day24.py
Normal file
64
2019/tests/test_day24.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import io
|
||||
|
||||
import pytest
|
||||
|
||||
from aoc2019.day24 import read_board, advance_board, part1
|
||||
|
||||
SAMPLE_START = """\
|
||||
....#
|
||||
#..#.
|
||||
#..##
|
||||
..#..
|
||||
#....
|
||||
"""
|
||||
|
||||
SAMPLE_STATES = """\
|
||||
....#
|
||||
#..#.
|
||||
#..##
|
||||
..#..
|
||||
#....
|
||||
|
||||
#..#.
|
||||
####.
|
||||
###.#
|
||||
##.##
|
||||
.##..
|
||||
|
||||
#####
|
||||
....#
|
||||
....#
|
||||
...#.
|
||||
#.###
|
||||
|
||||
#....
|
||||
####.
|
||||
...##
|
||||
#.##.
|
||||
.##.#
|
||||
|
||||
####.
|
||||
....#
|
||||
##..#
|
||||
.....
|
||||
##...
|
||||
""".split("\n\n")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cycles,state", enumerate(SAMPLE_STATES))
|
||||
def test_evolution_part1(cycles: int, state: str) -> None:
|
||||
with io.StringIO(SAMPLE_START) as f:
|
||||
board = read_board(f)
|
||||
|
||||
with io.StringIO(state) as f:
|
||||
final_state = read_board(f)
|
||||
|
||||
for _ in range(cycles):
|
||||
board = advance_board(board)
|
||||
|
||||
assert board == final_state
|
||||
|
||||
|
||||
def test_sample_part1() -> None:
|
||||
with io.StringIO(SAMPLE_START) as f:
|
||||
assert part1(f) == 2129920
|
||||
Reference in New Issue
Block a user