20 lines
413 B
Python
20 lines
413 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
INPUT_FILE = 'input.txt'
|
||
|
|
||
|
def main():
|
||
|
left, right = [], []
|
||
|
contents = open(INPUT_FILE, 'r').readlines()
|
||
|
for line in contents:
|
||
|
fields = line.split(' ')
|
||
|
left.append(int(fields[0]))
|
||
|
right.append(int(fields[-1]))
|
||
|
similarity = 0
|
||
|
for id in left:
|
||
|
similarity += id * right.count(id)
|
||
|
print(similarity)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|