Skip to content

Instantly share code, notes, and snippets.

@glitchcowboy
Last active January 8, 2024 20:31
Show Gist options
  • Save glitchcowboy/4e16e8d371350bee66c0525e5d9e6bf8 to your computer and use it in GitHub Desktop.
Save glitchcowboy/4e16e8d371350bee66c0525e5d9e6bf8 to your computer and use it in GitHub Desktop.
Glitchcowboy's Day4 part 1 in python
import pandas as pd
#borrowed some things from deom23
def main():
df = pd.read_csv('input.txt', delim_whitespace=True, header=None)
total_score = 0
for row in range(df.shape[0]):
row_score = 0
winners, numbers_i_have = df.iloc[row, 2:12].tolist(), df.iloc[row, 13:39].tolist()
correct = [x for x in numbers_i_have if x in winners]
row_score = 0 if len(correct) == 0 else 2 ** (len(correct) - 1)
total_score += row_score
print("total score: ", total_score)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment