2023-4-1
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
with open("input.txt", "r") as f:
|
||||
score = 0
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
(winners, cards) = line.split(" | ")
|
||||
winners = list(winners.split(": ")[1].split(" "))
|
||||
cards = cards.split(" ")
|
||||
print(winners)
|
||||
print(cards)
|
||||
count = 0
|
||||
for card in cards:
|
||||
if card:
|
||||
if card in winners:
|
||||
count += 1
|
||||
if count > 0:
|
||||
score += 2 ** (count - 1)
|
||||
print(score)
|
||||
Reference in New Issue
Block a user