You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 년 전
1234567891011121314151617181920
  1. import sys
  2. from math import prod
  3. def slide(step):
  4. dx, dy = step
  5. seen, x, y = 0, 0, 0
  6. while y + dy < height:
  7. x += dx
  8. y += dy
  9. seen += grid[y][x % width] == '#'
  10. return seen
  11. grid = sys.stdin.read().splitlines()
  12. height = len(grid)
  13. width = len(grid[0])
  14. print(slide((3, 1)))
  15. print(prod(map(slide, [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)])))