2024 Dec 02nd

This commit is contained in:
Julia Lange 2024-12-02 10:13:15 -08:00
parent 564643c001
commit 8fa58eca1b
Signed by: Julia
SSH key fingerprint: SHA256:KI8YxpkPRbnDRkXPgCuQCVz181++Vy7NAvmQj8alOhM

28
Python/2024/02/main.py Normal file
View file

@ -0,0 +1,28 @@
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)