Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223
  1. def main():
  2. with open("input3.txt") as file:
  3. lines = file.readlines()
  4. grid = [list(line.strip()) for line in lines]
  5. print(grid[0])
  6. wrap = len(grid[0])
  7. coords = [0,0] # x, y - across, down
  8. trees = 0
  9. while coords[1] < len(grid):
  10. print(coords)
  11. if grid[coords[1]][coords[0]] == "#":
  12. trees += 1
  13. coords[0] = coords[0] + 3
  14. coords[1] = coords[1] + 1
  15. if coords[0] >= wrap:
  16. coords[0] = coords[0] - wrap
  17. print(f"It's been a long toboggan trip, and I encountered {trees} trees.")
  18. if __name__ == "__main__":
  19. main()