Initial commit
This commit is contained in:
commit
97a4330bc0
110 changed files with 7006 additions and 0 deletions
26
2024/1/one.py
Normal file
26
2024/1/one.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
listl = []
|
||||
listr = []
|
||||
with open("input") as lines:
|
||||
for line in lines.readlines():
|
||||
line = line.rstrip()
|
||||
print(line)
|
||||
spli = line.split(" ")
|
||||
listl.append(int(spli[0]))
|
||||
listr.append(int(spli[-1]))
|
||||
|
||||
assert len(listl) == len(listr)
|
||||
|
||||
listl.sort()
|
||||
listr.sort()
|
||||
|
||||
dtot = 0
|
||||
|
||||
for i in range(len(listl)):
|
||||
l = listl[i]
|
||||
r = listr[i]
|
||||
d = abs(l-r)
|
||||
dtot += d
|
||||
print(l, r, d)
|
||||
|
||||
print(dtot)
|
25
2024/1/two.py
Normal file
25
2024/1/two.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
listl = []
|
||||
listr = []
|
||||
with open("input") as lines:
|
||||
for line in lines.readlines():
|
||||
line = line.rstrip()
|
||||
print(line)
|
||||
spli = line.split(" ")
|
||||
listl.append(int(spli[0]))
|
||||
listr.append(int(spli[-1]))
|
||||
|
||||
assert len(listl) == len(listr)
|
||||
|
||||
listl.sort()
|
||||
listr.sort()
|
||||
|
||||
dtot = 0
|
||||
|
||||
for i in range(len(listl)):
|
||||
l = listl[i]
|
||||
d = listr.count(l) * l
|
||||
dtot += d
|
||||
print(l, d)
|
||||
|
||||
print(dtot)
|
Loading…
Add table
Add a link
Reference in a new issue