This commit is contained in:
Tyrel Souza 2023-12-04 10:39:22 -05:00
parent f6ad7bc22d
commit 56afef37d7
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E

View File

@ -17,7 +17,8 @@ def load_cards(rows):
have_numbers=have_numbers,
have=have,
have_count=len(have),
points=0
points=0,
refs=0
)
if have:
points = 1
@ -29,18 +30,25 @@ def load_cards(rows):
# @shared.profile
def part1(cards):
print(sum(card['points'] for _, card in cards.items()))
print(cards[1].keys())
# @shared.profile
def part2(cards):
card_ids = list(range(len(cards)+1))
# 'winning_numbers', 'have_numbers', 'have', 'have_count', 'points'
for card_id, card in cards.items():
nn = [x+card_id for x in range(card['have_count'])]
breakpoint()
nn = [x+1+card_id for x in range(card['have_count'])]
if not nn:
continue
# One point for initially having the card
for idx in nn:
cards[idx]['refs'] += 1
# X more points for how many times this card is referenced
for _ in range(card['refs']):
for idx in nn:
cards[idx]['refs'] += 1
# Sum the ref counts, and then add the total cards in
print(sum(card['refs'] for _, card in cards.items()) +len(cards))
def main():