Opening your workspace…
Workspace/Coding room
Opening your workspace…
The last ferry is pulling away from the dock, and I’m on the wrong side of a bridge with half its planks missing. The ferryman’s a troll. He’ll wait for the bell, so all I gotta do is get across and smack it with my bat.
I start on plank 0. A short hop takes me one plank forward. A double jump takes me two planks forward, and I can sail right over a hole. Landing in a hole is out. My enchanted sneakers are ready for a double jump at the start, but after each double jump I have to make a short hop before I can double jump again.
What’s the fewest moves I need to reach the bell on the last plank? Each short hop or double jump counts as one move. Return -1 if I can’t reach it.
"#.##.#"Output3I jump from 0 to 2, hop to 3, then jump to 5. Two moves could cover at most four planks.
"###.#"Output3Jumping straight to 2 leaves me facing a hole with tired sneakers. Two short hops get me to 2 with my double jump ready, so I can clear the hole and land on 4.
Track the best arrivals with and without a charged double jump.
function solve(bridge) { // 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.