20 lines
331 B
Python
20 lines
331 B
Python
""" day 1 part 2 """
|
|
|
|
import collections
|
|
import fileinput
|
|
|
|
left = collections.defaultdict(lambda:0)
|
|
right = collections.defaultdict(lambda:0)
|
|
|
|
for line in fileinput.input():
|
|
a, b = line.split()
|
|
left[int(a)] += 1
|
|
right[int(b)] += 1
|
|
|
|
total = 0
|
|
|
|
for key, val in left.items():
|
|
total += val*key*right[key]
|
|
|
|
print(total)
|