Opening your workspace…
Workspace/Coding room
Opening your workspace…
Peel Shrek’s onion. He’s trying to explain to Donkey that ogres have layers, and Donkey wants a count. The grid shows a slice of onion: # is onion and . is empty space. In one peel, remove every onion cell that shares an edge with empty space or the outside of the grid. Remove those cells together. How many peels does it take to clear the slice?
["#####"]Output1Every cell touches the outside along its top edge, so the whole strip comes off in one peel.
[".#.","###",".#."]Output2The four tips come off first. The center touches empty space only diagonally at first, so it lasts until the second peel.
# and ..Peel all exposed cells together. The next layer is formed by their still-occupied neighbors.
function solve(slice) { // 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.