8000 2024-01 · viliampucik/adventofcode@4d2f1d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d2f1d8

Browse files
Viliam PucikViliam Pucik
authored andcommitted
2024-01
1 parent 75ee42c commit 4d2f1d8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

2024/01.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
from collections import Counter
3+
4+
left, right = zip(*(map(int, line.split()) for line in open(0)))
5+
rcounts = Counter(right)
6+
7+
print(sum(abs(l - r) for l, r in zip(sorted(left), sorted(right))))
8+
print(sum(l * rcounts[l] for l in left))

0 commit comments

Comments
 (0)
0