Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • +1 I used US currency because most of the users of this site are our Colonial cousins. I would have preferred to ask for a general algorithm, but was afraid of the "that's an opinion" police. Btw, despite my upvote, you have entirely missed the point of the question, which is something like - "all published articles posit an infinite number of each denomination - what happens In Real Life, when some denominations are missing, scarce or overly abundant". Fell free to post another answer :-) Commented Oct 14, 2016 at 19:56
  • 2
    In real life, the greedy algorithm still works, regardless of the relative abundance or scarcity of particular coins. Alternative algorithms are reserved for hypothetical coin systems, and are therefore only interesting in the abstract (unless you happen to know of a modern coin system that is not based on 1's, 5's & 10's). Commented Oct 14, 2016 at 19:58
  • 3
    @RobertHarvey: I think there are systems that have 0.50, 0.25, 0.10 and 0.05 coins, where greedy algorithm wouldn't work (if you need to return 0.30 and have plenty of 0.25 and 0.10 but no 0.05 coins). One example would be the USA. Commented Oct 15, 2016 at 13:10