From cb247a773dfb1550621a5fa7cffb7473ac04aa99 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Mon, 31 Oct 2022 10:52:05 +0100 Subject: Added day 16 --- day15/__init__.py | 8 ++------ day15/test_init.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'day15') diff --git a/day15/__init__.py b/day15/__init__.py index 38126fc..9eb94d9 100644 --- a/day15/__init__.py +++ b/day15/__init__.py @@ -116,17 +116,13 @@ class AssignmentOne(Assignment): example_result = 40 class AssignmentTwo(Assignment): - example_result = 315 - - @classmethod - def overflow(self, item): - return item - 9 if item > 9 else item + example_result = 315 @classmethod def increase_map(cls, map) -> Map: return [ [ - cls.overflow(item + dx + dy) + ((item + dx + dy - 1) % 9) + 1 for dx in range(5) for item in row ] diff --git a/day15/test_init.py b/day15/test_init.py index e5f10b0..e72e0e2 100644 --- a/day15/test_init.py +++ b/day15/test_init.py @@ -11,11 +11,9 @@ def test_icrease_map(): ] assert AssignmentTwo.increase_map([ - [0], - [1] + [1], + [2] ]) == [ - [0, 1, 2, 3, 4], - [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [2, 3, 4, 5, 6], @@ -23,15 +21,17 @@ def test_icrease_map(): [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [4, 5, 6, 7, 8], - [5, 6, 7, 8, 9] + [5, 6, 7, 8, 9], + [5, 6, 7, 8, 9], + [6, 7, 8, 9, 1] ] assert AssignmentTwo.increase_map([ - [0, 1], + [1, 2], ]) == [ - [0, 1, 1, 2, 2, 3, 3, 4, 4, 5], [1, 2, 2, 3, 3, 4, 4, 5, 5, 6], [2, 3, 3, 4, 4, 5, 5, 6, 6, 7], [3, 4, 4, 5, 5, 6, 6, 7, 7, 8], - [4, 5, 5, 6, 6, 7, 7, 8, 8, 9] + [4, 5, 5, 6, 6, 7, 7, 8, 8, 9], + [5, 6, 6, 7, 7, 8, 8, 9, 9, 1] ] -- cgit v1.2.3