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
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))
si
Op Thursday 30 Apr 2015 04:55 CEST schreef Ian Kelly:
> On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof 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
On Wed, Apr 29, 2015 at 6:11 PM, Steven D'Aprano
wrote:
> On Thu, 30 Apr 2015 05:57 am, Ian Kelly wrote:
>
>> On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof
>> wrote:
>>> I was wondering if there is a way to do this:
>>> for del_index in range((sieve_len // skip_count) * skip_count
On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof 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.
>
> It is cer
Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
> On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof 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
On Thu, 30 Apr 2015 05:57 am, Ian Kelly wrote:
> On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof
> 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_c
On Wed, Apr 29, 2015 at 2:45 PM, Cecil Westerhof 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 usin
On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof 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 to the end
Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly:
> On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof 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
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof 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
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
12 matches
Mail list logo