kuroko/test/day3.krk

17 lines
530 B
Plaintext
Raw Normal View History

2021-01-04 13:59:11 +03:00
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
2021-01-04 13:59:11 +03:00
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))