andewK

Untitled

May 12th, 2021
455
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def it(y, x):
  2.     posx, posy = 0, 0
  3.     while posy < 323:
  4.         yield posx % 31, posy
  5.         posy += y
  6.         posx += x
  7.  
  8.  
  9. file = open('input.txt')
  10. lines = list(map(list, file.readlines()))
  11.  
  12. for i in range(len(lines)):
  13.     lines[i] = lines[i][:-1]
  14.    
  15. L = [[1,1], [1,3], [1,5], [1,7], [2, 1]]
  16. trees = [0] * 5
  17. position = [[0, 0]] * 5
  18.  
  19. for i in range(5):
  20.     for posx, posy in it(*L[i]):
  21.         trees[i] += ("#" == lines[posy][posx])
  22.  
  23. print(trees, trees[0]*trees[1]*trees[2]*trees[3]*trees[4])
  24.  
  25.  
RAW Paste Data