aoc2024/d01/run.py

14 lines
282 B
Python

import sys, os
from collections import Counter
L1 = []
L2 = []
for l in sys.stdin.readlines():
[a,b] = l[:-1].split(" ")
L1.append(int(a))
L2.append(int(b))
C2 = Counter(L2)
print(sum(abs(b-a) for a, b in zip(sorted(L1), sorted(L2))),
sum(n * C2[n] for n in L1))