Upload files to "/"

This commit is contained in:
2024-12-02 21:09:21 +01:00
commit 7cb33df98e
5 changed files with 2042 additions and 0 deletions

18
01.py Normal file
View File

@@ -0,0 +1,18 @@
left = []
right = []
with open('input01.txt') as file:
for line in file:
left.append(line.split()[0])
right.append(line.split()[1])
left.sort()
right.sort()
out = 0
for i in range(0,len(left)):
cnt = 0
for j in range(0,len(right)):
if right[j] > left[i]:
out += int(left[i])*cnt
break
elif right[j] == left[i]:
cnt += 1
print(out)

24
02.py Normal file
View 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)

BIN
README.md Normal file

Binary file not shown.

1000
input01.txt Normal file

File diff suppressed because it is too large Load Diff

1000
input02.txt Normal file

File diff suppressed because it is too large Load Diff