adventofcode-2020/03/part1

26 lines
506 B
Plaintext
Raw Normal View History

2020-12-12 13:28:18 +01:00
#!/usr/bin/python3
slope = []
with open("input") as fh:
for ln in fh:
row = []
for c in ln:
if c == "#":
row.append(True)
elif c == ".":
row.append(False)
elif c == "\n":
pass
else:
raise RuntimeError("impossible")
slope.append(row)
xmod = len(slope[0])
x = 0
y = 0
trees = 0
while y < len(slope):
trees += slope[y][x % xmod]
x += 3
y += 1
print(trees)