Skip to content

Instantly share code, notes, and snippets.

@tonytx05
Created December 3, 2024 02:30
Show Gist options
  • Save tonytx05/1fe0bfd2e5e458c51a95c2b9b89c9b37 to your computer and use it in GitHub Desktop.
Save tonytx05/1fe0bfd2e5e458c51a95c2b9b89c9b37 to your computer and use it in GitHub Desktop.
"""
Description: Advent of Code 2024 day 1 puzzle 2
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)
score = 0
for row in df.iterrows():
matches = df[0].size-df[1].eq(row[1][0]).value_counts()[False]
score = score + matches * row[1][0]
print(score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment