|
|
@@ -0,0 +1,23 @@ |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
with open("input3.txt") as file: |
|
|
|
lines = file.readlines() |
|
|
|
grid = [list(line.strip()) for line in lines] |
|
|
|
print(grid[0]) |
|
|
|
wrap = len(grid[0]) |
|
|
|
coords = [0,0] # x, y - across, down |
|
|
|
trees = 0 |
|
|
|
while coords[1] < len(grid): |
|
|
|
print(coords) |
|
|
|
if grid[coords[1]][coords[0]] == "#": |
|
|
|
trees += 1 |
|
|
|
coords[0] = coords[0] + 3 |
|
|
|
coords[1] = coords[1] + 1 |
|
|
|
if coords[0] >= wrap: |
|
|
|
coords[0] = coords[0] - wrap |
|
|
|
print(f"It's been a long toboggan trip, and I encountered {trees} trees.") |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
main() |