diff options
author | mhsn <mail@mhsn.net> | 2024-12-01 12:03:00 +0000 |
---|---|---|
committer | mhsn <mail@mhsn.net> | 2024-12-01 12:03:00 +0000 |
commit | 326242bf41ba4da4f43f1509cae59a7817994c1c (patch) | |
tree | 915c59ccafffaa9bde16d69e55a178824b59e239 | |
parent | 80a23b6e29b251aadbe72c9fba23176aabae0b56 (diff) | |
download | aoc-326242bf41ba4da4f43f1509cae59a7817994c1c.tar.gz aoc-326242bf41ba4da4f43f1509cae59a7817994c1c.zip |
2024-01 python p1,p2
-rw-r--r-- | 2024/01/python/main.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/2024/01/python/main.py b/2024/01/python/main.py new file mode 100644 index 0000000..f920d5d --- /dev/null +++ b/2024/01/python/main.py @@ -0,0 +1,12 @@ +from collections import Counter +from fileinput import input + +L, R = zip(*[[int(n) for n in s.split()] for s in input()]) + +silver = sum(abs(left - right) for left, right in zip(sorted(L), sorted(R))) + +L, R = Counter(L), Counter(R) +gold = sum(n * L[n] * R[n] for n in list(L & R)) + +print("silver:", silver) +print("gold:", gold) |