Question: Task 2 : Manage two full lanes with the help with an empty spot, the bubble. The possible moves of a bubble are illustrated below.
Task : Manage two full lanes with the help with an empty spot, the bubble.
The possible moves of a bubble are illustrated below.
Code O shift bubble to the Other lane":
Code L shift bubble to the next Lower index:
Code H shift bubble to the next Higher index:
def swaptofront parkinglane, servicelane, car:
Description: This function returns a list of move codes for the bubble to swap places with other
cars so that eventually the specified car shifts to the front of its lane.
Parameters: parkinglane list of strings of the license plates or empty slot in the parking lane
servicelane list of strings of the license plates or empty slot in the service lane
car str representing the license plate of the car that needs to be brought to the frontAssumptions: car is an element in one of the parkinglane or servicelane lists
parkinglane and servicelane have equal lengths
parkinglane and servicelane together do not contain any
duplicate strings
parkinglane and servicelane together contain the empty string
in exactly one item.
Return value: A list str representing the codes of bubble moves that bring
car to occupy the slot at index in the lane list that contains car.
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
