advent-of-code/2017-python/tests/day_07_tests.py

43 lines
1.1 KiB
Python
Raw Normal View History

2021-11-01 16:40:46 +01:00
import unittest
from solutions.day_07 import Solution, Program
class Day7TestCase(unittest.TestCase):
def setUp(self):
2025-05-06 20:14:58 +02:00
self.puzzle_input = """
2021-11-01 16:40:46 +01:00
pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
ugml (68) -> gyxo, ebii, jptl
gyxo (61)
cntj (57)
2025-05-06 20:14:58 +02:00
""".strip()
2021-11-01 16:40:46 +01:00
self.solution = Solution()
def test_find_bottom_tower(self):
2025-05-06 20:14:58 +02:00
p = Program("ugml (68) -> gyxo, ebii, jptl")
assert p.name == "ugml"
2021-11-01 16:40:46 +01:00
assert p.weight == 68
2025-05-06 20:14:58 +02:00
assert p.disc == ("gyxo", "ebii", "jptl")
p = Program("jptl (61)")
assert p.name == "jptl"
2021-11-01 16:40:46 +01:00
assert p.weight == 61
assert p.disc == ()
2025-05-06 20:14:58 +02:00
assert self.solution.solve(self.puzzle_input).name == "tknk"
2021-11-01 16:40:46 +01:00
def test_find_weight_correction(self):
corrected = self.solution.solve_again(self.puzzle_input)
assert corrected == 60
2025-05-06 20:14:58 +02:00
if __name__ == "__main__":
2021-11-01 16:40:46 +01:00
unittest.main()