parent
a7aa40381e
commit
cea2400d6f
1 changed files with 21 additions and 0 deletions
@ -0,0 +1,21 @@ |
||||
lines = [[int(n) for n in l.split()] for l in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
unsafe, unsafe2 = 0, 0 |
||||
|
||||
for report in lines: |
||||
if report[0] == report[1]: |
||||
unsafe += 1 |
||||
continue |
||||
|
||||
trend = -1 if report[0] > report[1] else 1 |
||||
|
||||
for i in range(len(report) -1): |
||||
if (trend == -1 and report[i] < report[i+1]) \ |
||||
or (trend == 1 and report[i] > report[i+1]) \ |
||||
or (report[i] == report[i+1]) \ |
||||
or (abs(report[i] - report[i+1]) > 3): |
||||
|
||||
unsafe += 1 |
||||
break |
||||
|
||||
print(len(lines)-unsafe) |
Loading…
Reference in new issue