This commit is contained in:
Sebastian Seedorf
2020-12-03 11:18:56 +01:00
parent c460fd9913
commit 13774dedbb
4 changed files with 363 additions and 1 deletions

28
day03/part2.py Normal file
View File

@@ -0,0 +1,28 @@
import operator
from functools import reduce
lines = [x.strip() for x in open("input.txt")]
pos = 0.0
count = 0
factors = []
def prod(iterable):
return reduce(operator.mul, iterable, 1)
for movement in [1, 3, 5, 7, 0.5]:
count = 0
for line in lines:
if isinstance(pos, int) or pos.is_integer():
pos = int(pos)
pos = pos % len(line)
if line[pos] == '#':
count += 1
pos += movement
factors.append(count)
pos = 0
print(factors)
print(prod(factors))