28 lines
624 B
Python
28 lines
624 B
Python
from functools import cmp_to_key
|
|
input = open("input", 'r')
|
|
|
|
data1 = []
|
|
|
|
for i, line in enumerate(input):
|
|
data1.append([int(val.strip()) for val in line.split(" ")])
|
|
|
|
sm = 0
|
|
sm2 = 0
|
|
|
|
def checkReport(report):
|
|
reportDiff = set([a - b for a , b in zip(report, report[1:])])
|
|
if reportDiff.issubset({1,2,3}):
|
|
return True
|
|
if reportDiff.issubset({-1,-2,-3}):
|
|
return True
|
|
return False
|
|
|
|
for report in data1:
|
|
sm += 1 if checkReport(report) else 0
|
|
for i in range(len(report)):
|
|
if checkReport(report[:i] + report[(i+1):]):
|
|
sm2 += 1
|
|
break
|
|
|
|
print(sm)
|
|
print(sm2)
|