Created
December 3, 2024 02:30
-
-
Save tonytx05/3172ea729ceaa3f35ea13aeceeba5a74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Description: Advent of Code 2024 day 1 puzzle 1 | |
Author: Anthony Allison | |
Date Created: 2 December 2024 | |
Date Modified: 2 December 2024 | |
Version: 1.0 | |
""" | |
import pandas as pd | |
widths = [5, 8] | |
df = pd.read_fwf('input.txt', widths=widths, header=None) | |
list1_sorted = df[0].sort_values(ignore_index=True) | |
list2_sorted = df[1].sort_values(ignore_index=True) | |
diff = list1_sorted.sub(list2_sorted).abs() | |
print(diff.cumsum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment