Files
adventofcode/2024/01/1.py

16 lines
308 B
Python

import numpy as np
# Load both columns into numpy arrays of type int
left, right = np.loadtxt("input", dtype=int).T
# Sort both lists (ASC)
left.sort()
right.sort()
# Just calculate the distances.
distances = np.abs(left - right)
distance = np.sum(distances)
print(f"The total distance is {distance}.")