Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import sys
  2.  
  3. black = {'N':'W','W':'S','S':'E','E':'N'}
  4. white = {'N':'E','E':'S','S':'W','W':'N'}
  5.  
  6. w, h = [int(i) for i in input().split()]
  7.  
  8. x,y = [int(i) for i in input().split()]
  9. ant = input()
  10.  
  11. t = int(input())
  12.  
  13. grid = []
  14. for i in range(h):
  15. grid.append(list(input()))
  16.  
  17. print(ant, file = sys.stderr)
  18. for i in range(t):
  19. ant = white[ant] if grid[y][x] == "." else black[ant]
  20. print(ant, grid[y][x],file=sys.stderr)
  21. grid[y][x] = "#" if grid[y][x] == "." else "."
  22. if ant == "N": y -= 1
  23. elif ant == "S": y +=1
  24. elif ant == "E": x -=1
  25. elif ant == "W": x +=1
  26.  
  27.  
  28. for i in grid:
  29. print(''.join(i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement