Author belopolsky
Recipients belopolsky, draghuram, mark.dickinson, rhettinger, stutzbach
Date 2010-05-13.20:57:01
SpamBayes Score 0.00856381
Marked as misclassified No
Message-id <1273784223.74.0.00521608011996.issue8692@psf.upfronthosting.co.za>
In-reply-to
Content
Daniel,

Your variant does not seem to work:

>>> def partial_product3(j, i):
...     a = [l << 1 | 1 for l in range(j, i + 1)]
...     n = len(a)
...     while 1:
...         if n == 1:
...             return a[0]
...         half = n//2
...         for k in range(0,half):
...             a[k] = a[k*2] * a[k*2+1]
...         if n & 1:
...             a[half] = a[n-1]
...         n = half

>>> partial_product3(4,6)
99
>>> 9 * 11 * 13
1287

but it looks like I posted a buggy version of partial_product2 as well.  Strange because I thought I had enough doctests to catch the errors.  I'll redo the testing.
History
Date User Action Args
2010-05-13 20:57:03belopolskysetrecipients: + belopolsky, rhettinger, mark.dickinson, draghuram, stutzbach
2010-05-13 20:57:03belopolskysetmessageid: <1273784223.74.0.00521608011996.issue8692@psf.upfronthosting.co.za>
2010-05-13 20:57:02belopolskylinkissue8692 messages
2010-05-13 20:57:01belopolskycreate