A
Atsuhiro Teshima
Jesús Gabriel y Galán wrote:
Hi Gesús, Thank for your advices!
Now,I'm trying to fix this problem.
Oh, obviously this code is better than mine.I'll fix it.
Atsuhiro Teshima
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