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: