From 1c3cb46e40e8a88b81ef746599cf2c522680c52a Mon Sep 17 00:00:00 2001 From: Andres Date: Sun, 15 Dec 2024 21:32:54 +0100 Subject: [PATCH] 2015 day 6 refactored a bit --- 2015/day-6/part-2.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/2015/day-6/part-2.py b/2015/day-6/part-2.py index bdcba44..cf2fc69 100644 --- a/2015/day-6/part-2.py +++ b/2015/day-6/part-2.py @@ -21,10 +21,7 @@ for line in lines: if instruction == "turn on": lights[(i, j)] += 1 elif instruction == "turn off": - if lights[(i, j)] == 0: - continue - else: - lights[(i, j)] -= 1 + lights[(i, j)] = max(0, lights[(i, j)] - 1) else: lights[(i, j)] += 2