26 lines
506 B
Python
Executable File
26 lines
506 B
Python
Executable File
#!/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)
|