Opening your workspace…
Workspace/Coding room
Opening your workspace…
Aang suggests a footrace. Toph suggests they hold it underground. She can feel people moving through solid rock with the soles of her feet, so she'd be happy to give him a head start.
You've drawn a map of the tunnels and written down where each racer plans to go. Everyone moves one tile at the same time when you blow the whistle. If two people finish a step on the same tile, call the race off. Two racers who simply trade places have made it past one another.
Return the first collision: the round (counting from 1), the two names in entry-list order, and the tile. If several pairs collide on the same whistle, choose the pair whose entry indices come first in lexicographic order. Return null if everyone gets through.
[{"name":"Toph","moves":"RR","start":[0,0]},{"name":"Aang","moves":"LL","start":[2,0]}]Output{"tile":[1,0],"first":"Toph","round":1,"second":"Aang"}Both racers finish the first step at [1,0].
[{"name":"Toph","moves":"R","start":[0,0]},{"name":"Katara","moves":"R","start":[1,0]},{"name":"Sokka","moves":"L","start":[2,0]}]Output{"tile":[1,0],"first":"Toph","round":1,"second":"Sokka"}Toph and Sokka meet at [1,0]. Katara finishes the step at [2,0].
U, D, L, and R; all strings have the same length.Move every racer first. Then inspect pairs in entry order.
function solve(racers) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.