[Tutor] Algorithm Question

Remco Gerlich scarblac@pino.selwerd.nl
Wed, 9 Jan 2002 15:42:29 +0100


On  0, Kirby Urner <urnerk@qwest.net> wrote:
> I modified this to sort the output, and gave it:
> 
>    >>> sums([5,11,15])
> 
> and got:
> 
> [31, 36, 41, 42, 46, 47, 51, 52, 53, 56, 57, 58, 61, 62,
> 63, 64, 66, 67, 68, 69, 71, 72,
> 
> etc. etc.
> 
> but shouldn't 5 + 2*15 = 30 be on the list?  I confess
> I never understood Daniel's description of what he needed
> very well.

My interpretation is that all numbers from the list must be present in the
sum, since they can be multiplied by 1 to 10, not 0. Therefore the lowest
number is 31=5+11+15. His own example with [5,10] started with 15, not 0, 5
or 10 (but those aren't sums). So it's not 100% clear. If they can be absent
from the sum as well, both range() calls should start from 0, not L[0] or 1.

-- 
Remco Gerlich