Question: PYTHON: The Vacuuminator needs to figure out how far it needs to travel to reach the nearest wall. Write a function distance _ to _

PYTHON: The Vacuuminator needs to figure out how far it needs to travel to reach the nearest wall.
Write a function distance_to_wall(world). This function should return an integer representing the smallest number of moves the Vacuuminator can make before hitting a wall.
If there are no walls present in the world, your function should return None.
Hint: Think about how you can calculate the number of moves the Vacuuminator can make before hitting a wall by using the number of rows and columns between the Vacuuminator and the wall. Also see the lecture recording on 25/3/2024 for some more guidance if you are having trouble. >>> distance_to_wall([['D','W'],['X','E']])
2
>>> distance_to_wall([['W','E'],['X','E']])
1
>>> distance_to_wall([['D','D'],['D','D'],['W','W'],['D','E'],['W','E'],['E','D'],['E','X']])
3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!