2025: improve folder names

This commit is contained in:
2024-12-19 14:02:43 +01:00
parent 9bca1dddca
commit dc7e94b7aa
21 changed files with 0 additions and 0 deletions

21
2024/02/1.py Normal file
View File

@ -0,0 +1,21 @@
verbose = True
safe = 0
unsafe = 0
with open("input", "r") as fp:
while line := fp.readline():
nums = list(map(int, line.split(" ")))
increasing = (nums[1] - nums[0]) > 0
for i in range(1, len(nums)):
diff = nums[i] - nums[i - 1]
if abs(diff) > 3 or abs(diff) == 0 or increasing != (diff > 0):
unsafe += 1
if verbose:
print(f"unsafe: {line}", end="")
break
else:
safe += 1
if verbose:
print(f" safe: {line}", end="")
print(f"Found {safe} safe and {unsafe} unsafe reports.")