Re: Help with small program

2007-01-01 Thread gokkog
"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 >

Re: Help with small program

2006-12-31 Thread Tom Plunket
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

Re: Help with small program

2006-12-31 Thread 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 > solution it provides will alw

Re: Help with small program

2006-12-29 Thread Tim Roberts
[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

Re: Help with small program

2006-12-27 Thread gokkog
"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

Re: Help with small program

2006-12-24 Thread Paul Watson
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__

Re: Help with small program

2006-12-24 Thread Paul Watson
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

Re: Help with small program

2006-12-24 Thread smartbei
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

Re: Help with small program

2006-12-24 Thread Felix Benner
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 >

Help with small program

2006-12-24 Thread smartbei
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 = (