advent-of-code-2024/day_01/part_b.py

11 lines
348 B
Python
Raw Normal View History

2024-12-04 23:00:43 +00:00
import aocd
def solve(data):
list_a, list_b = zip(*(map(int, line.split()) for line in data.split('\n')))
return sum(num*list_a.count(num)*list_b.count(num) for num in set(list_a))
if __name__ == '__main__':
solution = solve(aocd.get_data(year=2024, day=1))
print(solution)
aocd.submit(solution, year='2024', day=1, part='b')