27 lines
574 B
Python
Executable File
27 lines
574 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
|
|
with open("data.txt") as file:
|
|
lines = [line.rstrip() for line in file]
|
|
|
|
summa = 0
|
|
cards = []
|
|
for i in range(0, len(lines)):
|
|
cards.append(1)
|
|
|
|
for lineno in range(0, len(lines)):
|
|
splitted = lines[lineno].split(":")
|
|
splitted = splitted[1].split('|')
|
|
wins = splitted[0].split(" ")
|
|
numbers = splitted[1].split(" ")
|
|
wincount = 0
|
|
for i in numbers:
|
|
if i == '':
|
|
continue
|
|
if i in wins:
|
|
wincount += 1
|
|
cards[lineno + wincount] += cards[lineno]
|
|
|
|
print(cards)
|
|
print(sum(cards))
|