From 280432147afa7e81d0454570a240ab6edd0fe140 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Fri, 17 Nov 2023 21:50:50 -0800 Subject: [PATCH] day 11 --- tests/y_2015/test_2015_day11.py | 20 ++++++++------------ y_2015/day11.py | 3 +-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/y_2015/test_2015_day11.py b/tests/y_2015/test_2015_day11.py index a001ae8..cc6fc13 100644 --- a/tests/y_2015/test_2015_day11.py +++ b/tests/y_2015/test_2015_day11.py @@ -34,15 +34,11 @@ def test_pairs(): assert pairs("abbcegjk") is False -# def test_calculate_1(): -# day._Day__input_data = ["1"] -# day._apply_times = MagicMock() -# day._calculate_1() -# day._apply_times.assert_called_once_with(["1"], 40) -# -# -# def test_calculate_2(): -# day._Day__input_data = ["1"] -# day._apply_times = MagicMock() -# day._calculate_2() -# day._apply_times.assert_called_once_with(["1"], 50) +def test_calculate_1(): + day._Day__input_data = ["a"] + assert day._calculate_1() == "aabcc" + + +def test_calculate_2(): + day._Day__input_data = ["a"] + assert day._calculate_2() == "bbcdd" diff --git a/y_2015/day11.py b/y_2015/day11.py index 7f1cb5c..5be48ee 100644 --- a/y_2015/day11.py +++ b/y_2015/day11.py @@ -67,11 +67,10 @@ def _calculate_1(self) -> str: proposed_pwd = increment_string(self.__input_data) while not valid(proposed_pwd): proposed_pwd = increment_string(proposed_pwd) - self.cached_solution_1 = proposed_pwd return proposed_pwd def _calculate_2(self) -> str: - x = self.cached_solution_1 + x = self._calculate_1() proposed_pwd = increment_string(x) while not valid(proposed_pwd): proposed_pwd = increment_string(proposed_pwd)