add previous year
This commit is contained in:
24
2024/02/code.py
Normal file
24
2024/02/code.py
Normal file
@@ -0,0 +1,24 @@
|
||||
def test(arr):
|
||||
flagDown = int(arr[1])>int(arr[0])
|
||||
for i in range(1,len(arr)):
|
||||
diff = int(arr[i])-int(arr[i-1]) if flagDown else int(arr[i-1])-int(arr[i])
|
||||
if diff > 3 or diff < 1:
|
||||
return False
|
||||
return True
|
||||
|
||||
out = 0
|
||||
with open('input02.txt') as file:
|
||||
for line in file:
|
||||
arr = line.split()
|
||||
flagSafe = True
|
||||
if not test(arr):
|
||||
for k in range(0,len(arr)):
|
||||
fixarr = arr.copy()
|
||||
del fixarr[k]
|
||||
if test(fixarr):
|
||||
out += 1
|
||||
break
|
||||
else:
|
||||
out += 1
|
||||
|
||||
print(out)
|
||||
1000
2024/02/input02.txt
Normal file
1000
2024/02/input02.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user