L is a token that can only slide left, R is a token that can only slide right, and _ is an empty cell.
In one move, any token shifts one cell in its own direction, but only if that neighboring cell is empty. Tokens cannot jump over each other or leave the track.
You get two layouts of equal length, current and goal. Return True if goal can be reached from current in any number of moves (zero included), and False otherwise.current="R__L_", goal="_R_L_" → True
Shift the R token one cell to the right; the L token stays put.
current="_RL__", goal="__RL_" → False
To reach its spot the L token would have to move right, which it cannot do.
current="L__R", goal="_LR_" → False
Both tokens would have to move against their only allowed direction.
L, R and _current="R__L_", goal="_R_L_"
True
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.