from math import prod with open('input') as f: data = [line.strip() for line in f] w, h= (len(data[0]), len(data)) def count_trees(slope): trees = 0 x, y = slope while y < h: if data[y][x%w] == '#': trees += 1 x += slope[0] y += slope[1] return trees def solve_a(): return count_trees((3, 1)) def solve_b(): slopes = ((1, 1), (3, 1), (5, 1), (7, 1), (1, 2)) results = [count_trees(slope) for slope in slopes] print(results) return prod(results) print(solve_a()) print(solve_b())