diff --git a/2024/01.py b/2024/01.py new file mode 100755 index 0000000..ba23e87 --- /dev/null +++ b/2024/01.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +from collections import Counter + +left, right = zip(*(map(int, line.split()) for line in open(0))) +rcounts = Counter(right) + +print(sum(abs(l - r) for l, r in zip(sorted(left), sorted(right)))) +print(sum(l * rcounts[l] for l in left))