aoc2020/03/2.py
2020-12-03 14:19:46 +00:00

11 lines
457 B
Python

lines = open("input", "r").read().split("\n")
lines = [l for l in lines if l]
def treecount(r, d):
rows = [l for i, l in enumerate(lines) if i%d==0]
visited = [l[(i*r)%len(l)] for i, l in enumerate(rows)]
trees = [t for t in visited if t == "#"]
return len(trees)
print(treecount(1,1), treecount(3,1), treecount(5,1), treecount(7,1), treecount(1,2))
print(treecount(1,1) * treecount(3,1) * treecount(5,1) * treecount(7,1) * treecount(1,2))