replace index-based for loop with iteration through zip
This commit is contained in:
parent
aa8cb30920
commit
0ee7546cd2
1 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue