advent/2024/1/2.py

14 lines
309 B
Python
Raw Normal View History

2024-12-19 17:10:50 -06:00
from collections import Counter
input = [i.rstrip() for i in open("input").readlines()]
splitted = [i.split(' ') for i in input]
left = [int(i[0]) for i in splitted]
right = [int(i[1]) for i in splitted]
counted = Counter(right)
score = 0
for item in left:
score += item * counted[item]
print(score)