17 lines
493 B
Python
Executable File
17 lines
493 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
INPUT_FILE = 'input.txt'
|
|
|
|
def main():
|
|
reports = [list(map(int, vals.split())) for vals in open(INPUT_FILE, 'r').readlines()]
|
|
safe_reports = 0
|
|
for report in reports:
|
|
ok = all([1 <= abs(report[i] - report[i + 1]) <= 3 for i in range(len(report) - 1 )])
|
|
is_sorted = report == sorted(report) or report == sorted(report, reverse=True)
|
|
if ok and is_sorted: safe_reports += 1
|
|
|
|
print(safe_reports)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|