There's an ATM with unlimited money in bills of 10, 20, 50, 100, 200, and 500 dollars. You're given an amount of money n
to withdraw with 1<=n<=1500
.
Try to find the minimal number of bills that must be used to cash out n
, or output -1
if it's impossible.
Example:
solve(1250) => 4 bills (500x2, 50x1, 200x1)
solve 1500 => 3 bills ($500x3)
Tests:
solve(10)
solve(550)
solve(770)
Good luck~!
This challenge comes from Sanan07 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!