Browse Source

Day 3a

main
Noëlle 4 years ago
parent
commit
8407f089c6
1 changed files with 23 additions and 0 deletions
  1. 23
    0
      day3a.py

+ 23
- 0
day3a.py View File

@@ -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()

Loading…
Cancel
Save