advent/2024/1/1.py

14 lines
371 B
Python
Raw Permalink Normal View History

2024-12-19 17:10:50 -06:00
input = [i.rstrip() for i in open("input").readlines()]
splitted = [i.split(' ') for i in input]
left = [int(i[0]) for i in splitted]
left = sorted(left)
right = [int(i[1]) for i in splitted]
right = sorted(right)
output = []
for index in range(len(left)):
signed_dist = int(left[index]) - int(right[index])
output.append(abs(signed_dist))
print(sum(output))