diff --git a/day_02/program.py b/day_02/program.py index a85eb07..f02822f 100755 --- a/day_02/program.py +++ b/day_02/program.py @@ -18,13 +18,13 @@ def get_report_entries(lines: list) -> list: def is_safe_single(reports: list) -> bool: increasing = True decreasing = True - for i in range(len(reports) - 1): - distance = abs(reports[i] - reports[i + 1]) + for a, b in zip(reports, reports[1:]): + distance = abs(a - b) if distance == 0 or distance > 3: return False - if reports[i] > reports[i + 1]: + if a > b: increasing = False - if reports[i] < reports[i + 1]: + if a < b: decreasing = False return increasing or decreasing