An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
Daily Challenge 262 - No One Likes Spare Change
No one enjoys carrying around spare change. And to avoid all that jingling it's absolutely necessary to have an efficient algorithm to calculate the minimum number of coins needed to pay for something. So given a set of coin denominations determine the fewest number of coins required to add up to a given amount. Coin denominations WILL NOT be standard.
Example
US Currency includes the penny, nickel, dime and quarter or the coins with denominations: [1, 5, 10, 25] If I were to ask you to make 75 cents you would just return 3 since 75 cents can be made with 3 quarters.
Denominations:
coins1={1,5,10,25};
coins2={1,2,5,10,20,50};
Tests:
coins1(123)
coins2(123)
coins1(75)
coins2(75)
Good luck!
This challenge comes from RasPat1 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 [email protected] with your suggestions!
Original Link: https://dev.to/thepracticaldev/daily-challenge-262-no-one-likes-spare-change-5op
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To