with open("input.txt","r") as f: tmap = f.read().split('\n') def trees(right, down, tmap=tmap): count = 0 for row, line in enumerate(tmap[::down]): # array slicing by step if line[ row * right % len(tmap[0]) ] == "#": count += 1 return count print(f'Part 1: {trees(3,1)}') print(f'Part 2: {trees(1,1)*trees(3,1)*trees(5,1)*trees(7,1)*trees(1,2)}')