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')