Op Thursday 30 Apr 2015 04:55 CEST schreef Ian Kelly:
On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof ce...@decebal.nl wrote:
Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
In that case you can definitely omit the middle term of the slice,
which will be both more concise and clearer
Because I want the code to work with Python 3 also, the code is now:
def lucky_numbers(n):
Lucky numbers from 1 up-to n
http://en.wikipedia.org/wiki/Lucky_number
if n 3:
return [1]
sieve = list(range(1, n + 1, 2))
On 04/30/2015 02:55 PM, Cecil Westerhof wrote:
Because I want the code to work with Python 3 also, the code is now:
def lucky_numbers(n):
Lucky numbers from 1 up-to n
http://en.wikipedia.org/wiki/Lucky_number
if n 3:
return [1]
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof ce...@decebal.nl wrote:
I was wondering if there is a way to do this:
for del_index in range((sieve_len // skip_count) * skip_count - 1,
skip_count - 2, -skip_count):
del
I wrote a function lucky_numbers:
def lucky_numbers(n):
if n 3:
return [1]
sieve = range(1, n + 1, 2)
sieve_index = 1
while True:
skip_count = sieve[sieve_index]
sieve_len = len(sieve)
if sieve_len skip_count:
Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly:
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof ce...@decebal.nl wrote:
I was wondering if there is a way to do this:
for del_index in range((sieve_len // skip_count) * skip_count - 1,
skip_count - 2, -skip_count):
del sieve[del_index]
On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof ce...@decebal.nl wrote:
Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly:
And although it's not clear to me what this is supposed to be doing,
you probably no longer need the middle term if the intention is to
continue deleting all the way
On Wed, Apr 29, 2015 at 2:45 PM, Cecil Westerhof ce...@decebal.nl wrote:
I was wondering if there is a way to do this:
for del_index in range((sieve_len // skip_count) * skip_count - 1,
skip_count - 2, -skip_count):
del sieve[del_index]
in a more efficient way.
You can delete using
On Thu, 30 Apr 2015 05:57 am, Ian Kelly wrote:
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof ce...@decebal.nl
wrote:
I was wondering if there is a way to do this:
for del_index in range((sieve_len // skip_count) * skip_count
- 1,
Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof ce...@decebal.nl wrote:
Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly:
And although it's not clear to me what this is supposed to be
doing, you probably no longer need the middle
On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof ce...@decebal.nl wrote:
Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
In that case you can definitely omit the middle term of the slice,
which will be both more concise and clearer in intent, though
probably not significantly faster.
On Wed, Apr 29, 2015 at 6:11 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Thu, 30 Apr 2015 05:57 am, Ian Kelly wrote:
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof ce...@decebal.nl
wrote:
I was wondering if there is a way to do this:
for del_index in
12 matches
Mail list logo