Help with small program

Tim Roberts timr at probo.com
Sat Dec 30 00:19:49 EST 2006


gokkog at yahoo.com wrote:
>
>Interesting impl in Python! I am wondering what if the requirement is
>to find the minimum number of coins which added to the "fin" sum...

Given the set of coins in the original problem (100, 10, 5, 1, 0.5), the
solution it provides will always be optimal.  Even if we change this to
American coinage (50, 25, 10, 5, 1), I believe it is still optimal.

It is certainly possible to construct a set of denominations for which the
algorithm occasionally chooses badly.  For example, if you give it the set
(40,35,10) and ask it to make change for 70, it will be suboptimal.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list