30 lines
689 B
Python
30 lines
689 B
Python
from collections import Counter
|
|
from itertools import pairwise
|
|
reports = [i.rstrip() for i in open("input").readlines()]
|
|
reports = [[int(j) for j in i.split(' ')] for i in reports]
|
|
|
|
def reduce_report_to_state(report):
|
|
p = pairwise(report)
|
|
|
|
diffs = [x - y for x, y in p]
|
|
absdiff = list(map(abs, diffs))
|
|
c = Counter(absdiff)
|
|
if c[0] > 0:
|
|
return False
|
|
signs = list(map(lambda x: x > 0, diffs))
|
|
signs = set(signs)
|
|
if len(signs) != 1:
|
|
return False
|
|
|
|
for i in absdiff:
|
|
if i < 1 or i > 3:
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
processed = map(reduce_report_to_state, reports)
|
|
counted = Counter(processed)
|
|
|
|
print(counted[True])
|