Opening your workspace…
Workspace/Coding room
Opening your workspace…
An ice-cream truck stops at its usual route. Each customer is listed by the number of cones they want. The driver has cones cones ready. Return the number of customers, starting from the front of the list, whose orders can be filled before the cones run out.
[2,1,3], 4Output2The first two customers need 2 + 1 = 3 cones. The third would bring the total to 6, beyond the 4 ready.
[1,2,1], 4Output3All three regulars can get their orders: 1 + 2 + 1 = 4 cones.
Serve orders from the front until the next customer needs more cones than remain.
function solve(orders, cones) { // 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.