This commit is contained in:
aaron
2023-12-04 22:45:05 +01:00
parent 3c98e216ae
commit 5b57327db2

View File

@@ -51,29 +51,23 @@ def new_rules(input_data: list) -> list:
Calculate the score for the updated rule set.
- If your card has n matches, get the next n cards
- repeat until there are no more matches
- return the total number of cards you've accumulated
"""
data = input_data.split("\n")
score, win, total = 0, 0, 0
cardcounts = []
for i in range(len(data)):
cardcounts.append(1)
for x, row in enumerate(data):
cards = [1 for i in range(len(data))]
win = 0
for i, row in enumerate(data):
wins = row.split("|")[0].split(":")[1].split()
nums = row.split("|")[1].split()
for num in nums:
if num in wins:
win += 1
if score == 0:
score = 1
else:
score *= 2
for i in range(win):
cardcounts[x + i + 1] += cardcounts[x]
total += score
score, win = 0, 0
return cardcounts
for j in range(win):
cards[i + j + 1] += cards[i]
win = 0
return cards
if __name__ == "__main__":