Implement day 22 part 1

This commit is contained in:
2021-07-03 14:15:11 +02:00
parent a43f260e1b
commit abc742e2ad
2 changed files with 87 additions and 0 deletions

43
2019/tests/test_day22.py Normal file
View File

@@ -0,0 +1,43 @@
import pytest
from aoc2019.day22 import shuffle
SAMPLE_INSTRUCTIONS = [
"""deal with increment 7
deal into new stack
deal into new stack""",
"""cut 6
deal with increment 7
deal into new stack""",
"""deal with increment 7
deal with increment 9
cut -2""",
"""deal into new stack
cut -2
deal with increment 7
cut 8
cut -4
deal with increment 7
cut 3
deal with increment 9
deal with increment 3
cut -1""",
]
CORRECT_SHUFFLES = [
"0 3 6 9 2 5 8 1 4 7",
"3 0 7 4 1 8 5 2 9 6",
"6 3 0 7 4 1 8 5 2 9",
"9 2 5 8 1 4 7 0 3 6",
]
@pytest.mark.parametrize('instructions,correct', zip(SAMPLE_INSTRUCTIONS, CORRECT_SHUFFLES))
def test_shuffle(instructions, correct):
instructions = [line.strip() for line in instructions.splitlines()]
correct = [int(i) for i in correct.split(" ")]
result = shuffle(instructions, 10)
assert result == correct