Skip to content

Commit 4ce62ac

Browse files
committed
Add solution to 2024-12-01
1 parent 6edfdda commit 4ce62ac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

2024/day01/solutions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from collections import Counter
2+
3+
with open("input") as f:
4+
ls = f.read().strip().split("\n")
5+
6+
l1, l2 = zip(*[map(int, x.split()) for x in ls])
7+
8+
# Part 1
9+
print(sum(abs(a - b) for a, b in zip(sorted(l1), sorted(l2))))
10+
11+
# Part 2
12+
cs = Counter(l2)
13+
print(sum(x * cs[x] for x in l1))

0 commit comments

Comments
 (0)