From: Atsuhiro Teshima Date: 2008-01-31T04:19:12+09:00 Subject: Re: Making Change (#154) Jes炭s Gabriel y Gal叩n wrote: Hi Ges炭s, Thank for your advices! > The first problem is that your solution returns > [10,1,1,1,1] for make_change(14, [10,7,1]) > when the correct answer would be [7,7]. Now,I'm trying to fix this problem. > To avoid iterating so much, check at Ilan Berci solution. > For each coin value, making a division you would know > how many of this coins can fit, something like (not tested): > > num = amount / coin > num.times {change << coin} > amount %= coin Oh, obviously this code is better than mine.I'll fix it. Atsuhiro Teshima -- Posted via http://www.ruby-forum.com/.