Added 2024 and day 1-3 solves in python

This commit is contained in:
d4rkr41n
2024-12-03 16:18:24 -06:00
parent f00e52f8a5
commit 2d5ce9ade1
12 changed files with 2441 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
with open("../input.txt", "r") as fp:
inputs = [list(map(int, line.rstrip().split())) for line in fp]
safe = 0
for line in inputs:
increase = 0
decrease = 0
unsafe = False
for i, a in enumerate(line[:-1]):
b = line[i+1]
# Check for difference of 1-3
if abs(a-b) > 3 or abs(a-b) < 1:
unsafe = True
break
# Watch for increase/decrease
if a < b:
increase += 1
else:
decrease += 1
if increase != 0 and decrease != 0:
unsafe = True
break
if not unsafe:
safe += 1
print(safe)