Opening your workspace…
Workspace/Coding room
Opening your workspace…
Help Ross, Rachel, and Chandler carry Ross’s couch up the stairwell. Start with the long side pointing along the first flight. Each flight has a step count and a direction of travel. If the next flight goes the same way, keep climbing. If it goes a different way, Ross yells “Pivot!” on the landing. Return how many steps you’ve climbed when he first yells, or -1 if you reach the top in silence.
[6,4,8], "NNE"Output10You climb 6 steps north and 4 more north. Ross yells at the turn east, before you climb any of the last 8 steps.
[3,7,5], "NSW"Output3The stairs double back after 3 steps. That first turn already gets a “Pivot!” out of Ross.
At a change of direction, count the flights already climbed.
function solve(steps, directions) { // 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.