advent-of-code/2015-python/tests/test_day_11.py
Anders Englöf Ytterström 838d06100b Solve 2015:11 "Corporate Policy"
I brainfarted and had a hard time trying to
understand the instructions.

> Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so on. Increase the rightmost letter one step; if it was z, it wraps around to a, and repeat with the next letter to the left until one doesn't wrap around.

I only managed to understand it by looking at solutions on the
subreddit, figuring out the correct behavior:

az -> ba, azzz -> baaa, azzzzz -> baaaaa etc.

I also sped up the test case containing `ghi` as initial password,
by looking for the leftmost invalid I, L or O and increase it,
replacing all following chars with `a`.

ghijklmn -> ghjaaaaa.
2023-11-20 20:54:43 +01:00

35 lines
954 B
Python

import unittest
from solutions.day_11 import Solution
class Day11TestCase(unittest.TestCase):
def setUp(self):
self.solution = Solution()
self.puzzle_input = self.solution.parse_input(
"""
<REPLACE ME>
"""
)
def test_parse_puzzle_input(self):
data = """
<REPLACE ME>
""".strip()
assert self.solution.parse_input(data) == "<REPLACE ME>"
def test_validate_passwords(self):
assert not self.solution.is_valid("hijklmmn")
assert not self.solution.is_valid("abbceffg")
assert not self.solution.is_valid("abbcegjk")
def test_solve_first_part(self):
assert self.solution.solve("abcdefgh") == "abcdffaa"
assert self.solution.solve("ghijklmn") == "ghjaabcc"
# def test_solve_second_part(self):
# assert self.solution.solve_again(self.puzzle_input) == True
if __name__ == "__main__":
unittest.main()