adventofcode/2024/01/02.py

20 lines
413 B
Python
Raw Normal View History

2024-12-01 12:51:05 +01:00
#!/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()