You are stuck in a multi-storey car parking lot. Your task is to exit the carpark using only the staircases. Exit is always at the bottom right of the ground floor.
Create a function that takes a two-dimensional list where:
012 and can be at any level of the car park.... and returns a list of the quickest route out of the carpark.
arr = [
[1, 0, 0, 0, 2],
[0, 0, 0, 0, 0]
]
# Starting from 2, move to left 4 times = "L4"
# Go down from stairs 1 step = "D1"
# Move to right 4 times to exit from right bottom corner = "R4"
result = ["L4", "D1", "R4"]
See the below examples to better understand:
parking_exit([
[1, 0, 0, 0, 2],
[0, 0, 0, 0, 0]
]) ➞ ["L4", "D1", "R4"]
parking_exit([
[2, 0, 0, 1, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 0]
]) ➞ ["R3", "D2", "R1"]
# Starting from 2, move to right 3 times = "R3"
# Go down from stairs 2 steps = "D2"
# Move to right 1 step to exit from right bottom corner = "R1"
parking_exit([[0, 0, 0, 0, 2]]) ➞ []
# You are already at right bottom corner.
N/A