From ec0ad80483918127691ad127ef5bfb4191ee6774 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 2 Dec 2024 16:37:45 +0900 Subject: [aoc/2024] Finish day 1 --- aoc/2024/01/part-two.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 aoc/2024/01/part-two.py (limited to 'aoc/2024/01/part-two.py') diff --git a/aoc/2024/01/part-two.py b/aoc/2024/01/part-two.py new file mode 100644 index 0000000..5000c9c --- /dev/null +++ b/aoc/2024/01/part-two.py @@ -0,0 +1,6 @@ +from sys import stdin +from collections import Counter + +left, right = zip(*((int(a), int(b)) for a, b in map(str.split, stdin))) +counter = Counter(right) +print(sum(counter[n]*n for n in left)) -- cgit 1.4.1