Question: write in python: We now wish to produce a sequence of moves to clean all of the dirt the Vacuuminator can find, and then return
write in python: We now wish to produce a sequence of moves to clean all of the dirt the Vacuuminator can find, and then return the Vacuuminator to its starting position. The Vacuuminator should repeatedly scan for and clean up dirt found from its current position according to the rules in Task It should continue to do so as long as it finds new dirt from its current position. We will call this a cleaning cycle.
Once the Vacuuminator is no longer able to find any new dirt, it should backtrack along its path, scanning for new dirt at each square. If it finds any new dirt in its scan it should begin a new cleaning cycle, starting with this dirt.
The Vacuuminator should continue until it has backtracked through every move it has made and found no more dirt, scanning and cleaning as it goes. Note that once the Vacuuminator has selected a patch of dirt to clean, it will not scan for any new dirt until that patch has been cleaned. Scanning for new dirt will only happen while the Vacuuminator is backtracking.
Write a function cleanpathworld This function should return a list of moves that the Vacuuminator will use to clean the world according to the rules above.
A working version of the Task pathtonextworld function is provided to help you with this task. Example example cases:
cleanpathEDEEEX
uudd
cleanpathDDEEEX
uulrdd
cleanpathEDEXDDEEE
rudrll
cleanpathEDEXDEEDE
rudduudl
cleanpathEDDDEEDEX
uulrdlldurrd
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
