15 lines
402 B
Python
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) |