advent-of-code/2024/1/one.py
2024-12-25 12:59:49 +01:00

27 lines
434 B
Python

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)