nmoneys
nmoneys copied to clipboard
Finite denominations when making optimal change
MakeOptimalChange()
works under the premise that the set of denominations that is passed is infinite, that is, we never "run out" of pieces for each denomination.
In the real-world, there is only a finite amount of pieces of each denomination. Change the algorithm (and change Denomination
as well) or create another method (taking, for instance a collection of FiniteDenomination
s) to support this real-world scenario.