Files
python-aoc-2020/day03/part2.py
2020-12-03 11:47:50 +01:00

27 lines
464 B
Python

import operator
from functools import reduce
lines = [x.strip() for x in open("input.txt")]
pos = 0
count = 0
factors = []
def prod(iterable):
return reduce(operator.mul, iterable, 1)
for x, y in [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]:
count = 0
for line in lines[::y]:
pos = pos % len(line)
if line[pos] == '#':
count += 1
pos += x
factors.append(count)
pos = 0
print(factors)
print(prod(factors))