Opening your workspace…
Workspace/Coding room
Opening your workspace…
The gang is stuck outside the house, and Scooby will only go in for Scooby Snacks. Given how many Snacks you have and how many Scooby needs to eat per step toward the door, find the fewest Snacks that will get him inside. If there aren't enough, return -1.
12, 3, 4Output12Four steps at three Scooby Snacks per step takes 12 Snacks, exactly what the gang has.
10, 4, 3Output-1Scooby needs 12 Snacks to make three steps, so ten won't get him inside.
Multiply the number of steps by the price per step and check the available snacks.
function solve(snacks, snacksPerStep, stepsToDoor) { // 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.