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 2: 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 swap_to_front (parking_lane, service_lane, 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: parking_lane (list of strings of the license plates or empty slot in the parking lane)
service_lane (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 front)Assumptions: car is an element in one of the parking_lane or service_lane lists
parking_lane and service_lane have equal lengths
parking_lane and service_lane together do not contain any
duplicate strings
parking_lane and service_lane 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 0 in the lane list that contains car.
Task 2 : Manage two full lanes with the help with

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!