Single Lane Fleet Migration
A single lane holds a row of carts and empty spots. The lane is given as a string where L is a cart that can only move left, R is a cart that can only move right, and X is an empty slot.
One move consists of swapping an adjacent pair in either direction allowed by the cart:
XLcan becomeLX(theLcart steps left into the empty slot)RXcan becomeXR(theRcart steps right into the empty slot)
No other swaps are permitted. Carts may never cross each other because they would need to occupy the same slot. Given two equal length strings start and target, determine whether start can be transformed into target using any number of allowed swaps.
The task is to decide feasibility, not to produce the sequence of moves.
Single Lane Fleet Migration
A single lane holds a row of carts and empty spots. The lane is given as a string where `L` is a cart that can only move left, `R` is a cart that can only move right, and `X` is an empty slot.