[Tutor] programming exercise in Python
Alan Gauld
alan.gauld at freenet.co.uk
Wed Aug 9 19:51:47 CEST 2006
>> # testsum = 0
>> # if k > 0:
>> # mult[k-1] = 0
>> # for j in range(k,lenmult):
>> # testsum = testsum + mpylist[j][1] * mult[j]
>
> My brain is bending with this bit! I'm not sure if its right or
> not...
>
> for k = 0, checks to see if it may add 1 to mult[0]
> for k = 1, sets mult[0] = 0, and checks to see if it may add 1 to
> mult[1]
> for k = 2, sets mult[1] = 0, and checks to see if it may add 1 to
> mult[2],
So you work along mult setting each member to zero after incrementing
it?
> The incr routine generates a vector of exponents to apply to the
> list
>
> mpylist [n] [0]
>
> m = product of mpylist [k] [0] ** mult[k]
>
But haven't you set all of mult[k] to zero, using the example
algorithm above?
> Experimentation will tell if this factor routine is as good as I
> would like
> it to be.
Its got me baffled, thats for sure! :-)
Alan G.
More information about the Tutor
mailing list