aoc2024/d01/run.py

14 lines
282 B
Python
Raw Permalink Normal View History

2024-12-01 10:36:21 +00:00
import sys, os
from collections import Counter
L1 = []
L2 = []
2024-12-01 14:35:36 +00:00
for l in sys.stdin.readlines():
2024-12-01 10:36:21 +00:00
[a,b] = l[:-1].split(" ")
L1.append(int(a))
L2.append(int(b))
C2 = Counter(L2)
2024-12-01 14:35:36 +00:00
print(sum(abs(b-a) for a, b in zip(sorted(L1), sorted(L2))),
sum(n * C2[n] for n in L1))