Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ToClean(environ):
- r = "right"
- l = "left"
- d = "down"
- c = "clean"
- direction = []
- last_d = 0
- first_d = []
- robot = 0
- count = 0
- count1 = 0
- for i, item in enumerate(environ):
- first_d.append(environ[i].index("d"))
- for i, item in enumerate(environ):
- for j, v in enumerate(item):
- if v == "d":
- last_d = j
- while robot <= last_d:
- if item[robot] == "d":
- direction.append(c)
- if robot < last_d:
- direction.append(r)
- elif item[robot] == "r":
- direction.append(r)
- elif item[robot] == "c":
- direction.append(r)
- robot += 1
- else:
- if count != len(environ) and count1 < len(first_d)-1:
- while last_d > first_d[count1+1]:
- direction.append(l)
- last_d -= 1
- robot = first_d[count1+1]
- else:
- direction.append(d)
- count1 += 1
- count = 0
- return direction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement