From d8bd434c0fb881a1445dbd71933b902428218afd Mon Sep 17 00:00:00 2001 From: Heiko Ludwig Date: Mon, 2 Dec 2024 11:06:00 +0100 Subject: [PATCH] some cleanups --- day_02/program.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/day_02/program.py b/day_02/program.py index 050e886..c726644 100755 --- a/day_02/program.py +++ b/day_02/program.py @@ -18,19 +18,15 @@ def get_report_entries(lines: list) -> list: def is_safe_single(reports: list) -> bool: increasing = True decreasing = True - safe = True for i in range(len(reports) - 1): + distance = abs(reports[i] - reports[i + 1]) + if distance < 1 or distance > 3: + return False if reports[i] >= reports[i + 1]: increasing = False if reports[i] <= reports[i + 1]: decreasing = False - distance = abs(reports[i] - reports[i + 1]) - if distance < 1 or distance > 3: - safe = False - pass - if safe and (increasing or decreasing): - return True - return False + return increasing or decreasing def is_safe_full(reports: list, dampener: bool) -> bool: