Opening your workspace…
Workspace/Coding room
Opening your workspace…
The first guest at the bathhouse in Spirited Away has put one toe in the water and taken it straight back out. Downstairs, Kamaji opens the furnace door. A crowd of little soot sprites is already halfway across the boiler room, each with a lump of coal over its head.
Starting at minute zero, each sprite delivers one lump per round trip. A sprite with a trip time of three minutes delivers at minutes 3, 6, 9, and so on. Given the sprites’ positive trip times and the number of lumps Kamaji needs to heat the bath, return the earliest minute when that many lumps have arrived. With zero lumps requested, return 0. There is at least one sprite.
[3], 4Output12The lone sprite delivers its four lumps at minutes 3, 6, 9, and 12.
[2,3], 4Output6By minute 5, three lumps have arrived, one each at minutes 2, 3, and 4. Both sprites arrive at minute 6, bringing the total to five.
At a proposed minute, add the completed trips and search for the earliest feasible time.
function solve(trip_times, lumps) { // 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.