Re: [Tutor] List Splicing

2009-06-18 Thread Lie Ryan
Luke Paireepinart wrote: > Robert Berman wrote: >> Emille, >> >> Thank you for the example of list splicing. Do you know if this is >> faster than a more conventional loop statement as in my code for >> primearray which is in my original post (reprinted here) > As has been mentioned, you will wan

Re: [Tutor] List Splicing

2009-06-17 Thread Luke Paireepinart
Robert Berman wrote: Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement as in my code for primearray which is in my original post (reprinted here) As has been mentioned, you will want to profile your code to know what is

Re: [Tutor] List Splicing

2009-06-17 Thread bob gailer
Robert Berman wrote: Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of a computational error

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emille, Thank you very much for the information on timeit. I will investigate and use it. >>... but this isn't what BuildSieve yields: >>> BuildSieve(20) >>[0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0] >>So I still don't know what primearray is/does. If you look at or pr

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Wayne, Thank you for the suggestion. I will let you know how well this plays out. Robert On Wed, 2009-06-17 at 19:26 -0500, Wayne wrote: > On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman > wrote: > Emille, > > Thank you for the example of list splicing. Do you know i

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 5:11 PM Robert Berman said... Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement Faster can be exactly determined using timeit. (for some definition of exact -- the one we use mostly around here anyway)

Re: [Tutor] List Splicing

2009-06-17 Thread Wayne
On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman wrote: > Emille, > > Thank you for the example of list splicing. Do you know if this is faster > than a more conventional loop statement as in my code for primearray which > is in my original post (reprinted here) > > The code is as follows: > > d

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement as in my code for primearray which is in my original post (reprinted here) The code is as follows: def BuildSieve(itemsin): TheSieve=list() TheSieve = range(0,itemsi

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 4:48 PM Robert Berman said... Emile, Thank your for your comments. I do have a list running from 0-101. Yes, it is true, I only needed 0 - 10 and yes I will change it. However, if you use primearray you haven't posted the primearray code... However, for the time being

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emile, Thank your for your comments. I do have a list running from 0-101. Yes, it is true, I only needed 0 - 10 and yes I will change it. However, if you use primearray as a sieve of all primes 2-100 you will see it works quite well. Printing a range, say primearray[21] through primear

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 3:03 PM Robert Berman said... Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of

[Tutor] List Splicing

2009-06-17 Thread Robert Berman
Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of a computational error but because of the drea