Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 24, 2020 01:26 pm GMT

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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To