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