Skip to content

Instantly share code, notes, and snippets.

@tonytx05
Created December 3, 2024 02:30
Show Gist options
  • Save tonytx05/3172ea729ceaa3f35ea13aeceeba5a74 to your computer and use it in GitHub Desktop.
Save tonytx05/3172ea729ceaa3f35ea13aeceeba5a74 to your computer and use it in GitHub Desktop.
"""
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