"Paul Watson 写道:
"
> Tim Roberts wrote:
> > [EMAIL PROTECTED] 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
>
Paul Watson wrote:
> > 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.
>
> Unless I am missing the point, the minimum n
Tim Roberts wrote:
> [EMAIL PROTECTED] 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 alw
[EMAIL PROTECTED] 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 c
"Paul Watson 写道:
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...
--
http://mail.python.org/mailman/listinfo/python-list
Better alternative.
cointype = (100, 10, 5, 1, 0.5)
def coins(fin):
needed = {}
for c in cointypes:
v, r = divmod(fin, c)
if v > 0:
needed[c] = v
fin = r
return needed
if __name__ == '__main__
smartbei wrote:
> Felix Benner wrote:
>> smartbei schrieb:
>>> Hello, I am a newbie with python, though I am having a lot of fun using
>>> it. Here is one of the excersizes I am trying to complete:
>>> the program is supposed to find the coin combination so that with 10
>>> coins you can reach a ce
Felix Benner wrote:
> smartbei schrieb:
> > Hello, I am a newbie with python, though I am having a lot of fun using
> > it. Here is one of the excersizes I am trying to complete:
> > the program is supposed to find the coin combination so that with 10
> > coins you can reach a certain amoung, take
smartbei schrieb:
> Hello, I am a newbie with python, though I am having a lot of fun using
> it. Here is one of the excersizes I am trying to complete:
> the program is supposed to find the coin combination so that with 10
> coins you can reach a certain amoung, taken as a parameter. Here is the
>
Hello, I am a newbie with python, though I am having a lot of fun using
it. Here is one of the excersizes I am trying to complete:
the program is supposed to find the coin combination so that with 10
coins you can reach a certain amoung, taken as a parameter. Here is the
current program:
coins = (
10 matches
Mail list logo