17 lines
530 B
Python
17 lines
530 B
Python
from fileio import open
|
|
let f = open('test/day3.in')
|
|
let lines = f.read().split('\n')[:-1]
|
|
|
|
def count_trees(lines, x_off, y_off):
|
|
let modulo = len(lines[0])
|
|
let x, y, trees = 0, 0, 0
|
|
while y < len(lines):
|
|
if lines[y][x % modulo] == '#':
|
|
trees += 1
|
|
x += x_off
|
|
y += y_off
|
|
return trees
|
|
|
|
print("part 1:", count_trees(lines, 3, 1))
|
|
print("part 2:", count_trees(lines, 1, 1) * count_trees(lines, 3, 1) * count_trees(lines, 5, 1) * count_trees(lines, 7, 1) * count_trees(lines, 1, 2))
|