some cleanups
This commit is contained in:
parent
89d34ce450
commit
d8bd434c0f
1 changed files with 4 additions and 8 deletions
|
|
@ -18,19 +18,15 @@ def get_report_entries(lines: list) -> list:
|
||||||
def is_safe_single(reports: list) -> bool:
|
def is_safe_single(reports: list) -> bool:
|
||||||
increasing = True
|
increasing = True
|
||||||
decreasing = True
|
decreasing = True
|
||||||
safe = True
|
|
||||||
for i in range(len(reports) - 1):
|
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]:
|
if reports[i] >= reports[i + 1]:
|
||||||
increasing = False
|
increasing = False
|
||||||
if reports[i] <= reports[i + 1]:
|
if reports[i] <= reports[i + 1]:
|
||||||
decreasing = False
|
decreasing = False
|
||||||
distance = abs(reports[i] - reports[i + 1])
|
return increasing or decreasing
|
||||||
if distance < 1 or distance > 3:
|
|
||||||
safe = False
|
|
||||||
pass
|
|
||||||
if safe and (increasing or decreasing):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def is_safe_full(reports: list, dampener: bool) -> bool:
|
def is_safe_full(reports: list, dampener: bool) -> bool:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue