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

11 lines
321 B
Python

import aocd
def solve(data):
pairs = zip(*(map(sorted, zip(*(map(int, line.split()) for line in data.split('\n'))))))
return sum(abs(a-b) for a,b in pairs)
if __name__ == '__main__':
solution = solve(aocd.get_data(year=2024, day=1))
print(solution)
aocd.submit(solution, year=2024, day=1, part='a')