Advertisement
Rew35

Untitled

Feb 15th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. def ToClean(environ):
  2. r = "right"
  3. l = "left"
  4. d = "down"
  5. c = "clean"
  6. direction = []
  7. last_d = 0
  8. first_d = []
  9. robot = 0
  10. count = 0
  11. count1 = 0
  12.  
  13. for i, item in enumerate(environ):
  14. first_d.append(environ[i].index("d"))
  15.  
  16. for i, item in enumerate(environ):
  17. for j, v in enumerate(item):
  18. if v == "d":
  19. last_d = j
  20.  
  21. while robot <= last_d:
  22. if item[robot] == "d":
  23. direction.append(c)
  24. if robot < last_d:
  25. direction.append(r)
  26. elif item[robot] == "r":
  27. direction.append(r)
  28. elif item[robot] == "c":
  29. direction.append(r)
  30. robot += 1
  31. else:
  32. if count != len(environ) and count1 < len(first_d)-1:
  33. while last_d > first_d[count1+1]:
  34. direction.append(l)
  35. last_d -= 1
  36. robot = first_d[count1+1]
  37. else:
  38. direction.append(d)
  39. count1 += 1
  40. count = 0
  41. return direction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement