mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
87 lines
1.6 KiB
Python
87 lines
1.6 KiB
Python
from io import StringIO
|
|
from textwrap import dedent
|
|
|
|
import pytest
|
|
|
|
from aoc2019.day10 import part1, part2
|
|
|
|
LARGE_SAMPLE = """\
|
|
.#..##.###...#######
|
|
##.############..##.
|
|
.#.######.########.#
|
|
.###.#######.####.#.
|
|
#####.##.#.##.###.##
|
|
..#####..#.#########
|
|
####################
|
|
#.####....###.#.#.##
|
|
##.#################
|
|
#####.##.###..####..
|
|
..######..##.#######
|
|
####.##.####...##..#
|
|
.#####..#.######.###
|
|
##...#.##########...
|
|
#.##########.#######
|
|
.####.#.###.###.#.##
|
|
....##.##.###..#####
|
|
.#.#.###########.###
|
|
#.#.#.#####.####.###
|
|
###.##.####.##.#..##
|
|
"""
|
|
|
|
|
|
@pytest.mark.parametrize('visible,field', [
|
|
(8, dedent("""\
|
|
.#..#
|
|
.....
|
|
#####
|
|
....#
|
|
...##
|
|
""")),
|
|
(33, dedent("""\
|
|
......#.#.
|
|
#..#.#....
|
|
..#######.
|
|
.#.#.###..
|
|
.#..#.....
|
|
..#....#.#
|
|
#..#....#.
|
|
.##.#..###
|
|
##...#..#.
|
|
.#....####
|
|
""")),
|
|
(35, dedent("""\
|
|
#.#...#.#.
|
|
.###....#.
|
|
.#....#...
|
|
##.#.#.#.#
|
|
....#.#.#.
|
|
.##..###.#
|
|
..#...##..
|
|
..##....##
|
|
......#...
|
|
.####.###.
|
|
""")),
|
|
(41, dedent("""\
|
|
.#..#..###
|
|
####.###.#
|
|
....###.#.
|
|
..###.##.#
|
|
##.##.#.#.
|
|
....###..#
|
|
..#.#..#.#
|
|
#..#.#.###
|
|
.##...##.#
|
|
.....#.#..
|
|
""")),
|
|
(210, LARGE_SAMPLE),
|
|
])
|
|
def test_samples_part1(visible: int, field: str) -> None:
|
|
data = StringIO(field.strip())
|
|
assert part1(data) == visible
|
|
|
|
|
|
def test_samples_part2():
|
|
data = StringIO(LARGE_SAMPLE.strip())
|
|
|
|
assert part2(data) == 802
|