advent_of_code/2024/1/1.py
2024-12-05 18:28:12 +01:00

22 lines
423 B
Python

#!/usr/bin/env python
# 2024 - Advent Of Code 1
# file = 'input_example.txt'
file = 'input.txt'
firsts = []
seconds = []
accum = 0
with open(file, encoding="utf-8") as f:
for line in f.readlines():
a, b, c, d = line.strip().split(' ')
firsts.append(int(a))
seconds.append(int(d))
firsts.sort()
seconds.sort()
for x, y in zip(firsts, seconds):
accum += abs(y - x)
print(f"sum: {accum}")