Opening your workspace…
Workspace/Coding room
Opening your workspace…
Your friend's Nether portal has gone dark. Across the magma causeway, she's tapping flint against the frame with a spoon. You have the steel she needs. She would also like you to bring the spoon back. It's her good spoon.
Your boots heat up with every step on magma and cool completely when you step on stone. You have one spare stone block. Before you cross, you can toss it onto any one magma square to make that square safe to step on. You may also keep it.
The string path shows the causeway from your end to hers, with M for magma and S for stone. You start with cool boots and step on every square in order. What's the smallest number of consecutive magma steps your boots must be able to take to get the steel to your friend?
"MMMMMSMM"Output2Cover the middle of the first five magma squares. Each hot stretch is now two steps long. One block can't break those first five into stretches of just one step.
"MMMSMMM"Output3Whichever stretch gets the block, the other still takes three magma steps.
A stone in the middle of the longest hot run leaves two shorter runs. The other runs stay intact.
function solve(path) { // 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.