1
This commit is contained in:
26
4/advent_1.py
Executable file
26
4/advent_1.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
|
||||
for line in lines:
|
||||
splitted = line.split(":")
|
||||
splitted = splitted[1].split('|')
|
||||
wins = splitted[0].split(" ")
|
||||
numbers = splitted[1].split(" ")
|
||||
reasumma = 0
|
||||
|
||||
print(wins)
|
||||
print(numbers)
|
||||
for i in numbers:
|
||||
if i == '':
|
||||
continue
|
||||
if i in wins:
|
||||
if reasumma == 0:
|
||||
reasumma = 1
|
||||
else:
|
||||
reasumma *= 2
|
||||
summa += reasumma
|
||||
print(summa)
|
||||
Reference in New Issue
Block a user