Opening your workspace…
Workspace/Coding room
Opening your workspace…
Award Gryffindor a few last-minute points at the end-of-year feast. The Great Hall is already decked out in Slytherin green, but Dumbledore still has a list of awards to announce. Give each award in full, in order, and stop the moment Gryffindor leads every other house. How many points does Dumbledore announce before the banners turn scarlet and gold? Return 0 if Gryffindor already leads, or -1 if the awards run out first.
[312,352,426,472], [50,50,60,10]Output170Ron's 50, Hermione's 50 and Harry's 60 bring Gryffindor level with Slytherin on 472. Neville's 10 make it 482, so Dumbledore awards 170 points in all.
[300,310,325,305], [20,10,50]Output30The first 20 leave Gryffindor five behind Ravenclaw. The next 10 put Gryffindor ahead on 330, so the final 50 stay unannounced.
Stop only after Gryffindor has passed every other house.
function solve(scores, awards) { // 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.