Opening your workspace…
Workspace/Coding room
Opening your workspace…
Help Winry repair Ed's automail arm in her Resembool workshop. Each bolt hole needs one bolt. A bolt can be up to 2 mm longer than the hole is deep because Winry can file down the excess. A shorter bolt won't hold. Fit as many holes as possible using the bolts on her bench, then return how many holes still need a bolt.
[10,8], [10,8]Output0Both bolts fit their matching holes exactly. Using the 10 mm bolt for the 8 mm hole would leave the deeper hole without a bolt.
[6,6,9], [8,12,5]Output2Winry can file the 8 mm bolt down to fit one 6 mm hole. The 5 mm bolt is too short for every hole, and even the 9 mm hole would require filing 3 mm off the 12 mm bolt.
Sort the holes and bolts. Fit each hole with the shortest remaining bolt that reaches.
function solve(depths, bolts) { // 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.