2023/day7/part1.py
2023-12-07 07:57:18 +01:00

15 lines
402 B
Python

from data_part1 import Hand
from pprint import pprint
input_file = 'input.txt'
hands = []
with open(input_file) as input:
while line:=input.readline():
cards, bid = line.replace("\n","").split(" ")
hands.append(Hand(cards=cards, bid=bid))
sorted_hands = sorted(hands)
pprint(sorted_hands)
sum = 0
for idx, hand in enumerate(sorted_hands):
sum += (idx + 1) * hand.bid
print(sum)