timm
This commit is contained in:
26
4/advent_2.py
Executable file
26
4/advent_2.py
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/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))
|
||||||
Reference in New Issue
Block a user