Shreesh bhat wrote:
Thank you all for helping me understand the overflow error.
I m a newbie on mailing lists.I apologize for my errors.
Program:
[snip code]
The program is executing correctly but it has to execute 16 seconds for
the constraints.
I have optimized the way i sum up digits
On 23/01/12 06:10, Shreesh bhat wrote:
def sieve(maxi):
primes = range(2,maxi+1)
You can reduce the size of primes by only storing the odd numbers.
range takes a third parameter that sets the stepsize, you cxan
use that to skip evens...
for i in primes:
j = 2
you can then start
Date: Sun, 22 Jan 2012 21:28:14 -0500
From: d...@davea.name
To: sur...@live.com
CC: tutor@python.org
Subject: Re: [Tutor] how to handle very large numbers
On 01/22/2012 09:08 PM, Surya K wrote:
Well,
I have been doing a puzzle where I have to deal with number 10^18. A
variable
On 01/23/2012 07:32 AM, Surya K wrote:
Date: Sun, 22 Jan 2012 21:28:14 -0500
From: d...@davea.name
To: sur...@live.com
CC: tutor@python.org
Subject: Re: [Tutor] how to handle very large numbers
On 01/22/2012 09:08 PM, Surya K wrote:
Well,
I have been doing a puzzle where I have to deal
I tried optimizing everything all things you guys pointed out and still its
orders of magnitude away from the expected result.
The program should check the islucky condition between range of (1,10**18)
numbers and iterate over that 10**5 times.
This program slows down more than 16 secs at
Shreesh bhat wrote:
I tried optimizing everything all things you guys pointed out and still
its orders of magnitude away from the expected result.
The program should check the islucky condition between range of (1,10**18)
numbers and iterate over that 10**5 times.
This program slows down
On Mon, Jan 23, 2012 at 06:43:50PM +0530, Shreesh bhat wrote:
The program should check the islucky condition between range of (1,10**18)
numbers and iterate over that 10**5 times.
How is the islucky condition defined?
The only version I have found is based on something quite similar to
On 23/01/12 13:13, Shreesh bhat wrote:
I tried optimizing everything all things you guys pointed out and still
its orders of magnitude away from the expected result.
That's what I suspected. It means the fundamental approach of testing
every number can probably never work.
Which approach
On 01/23/2012 01:20 PM, Alan Gauld wrote:
On 23/01/12 13:13, Shreesh bhat wrote:
I tried optimizing everything all things you guys pointed out and still
its orders of magnitude away from the expected result.
That's what I suspected. It means the fundamental approach of testing
every number
On 01/23/2012 08:13 AM, Shreesh bhat wrote:
I tried optimizing everything all things you guys pointed out and
still its
orders of magnitude away from the expected result.
The program should check the islucky condition between range of
(1,10**18)
numbers and iterate over that 10**5 times.
This
I have given the definition of lucky numbers and constraints involved at
the starting of the thread.
when a number's sum of digits and square of sum of digits is prime,it is
called lucky.
I already tried generating prime numbers using sieve of atkin algorithm
rather than doing primality test.
On Mon, Jan 23, 2012 at 10:51 AM, Shreesh bhat shreeshbha...@gmail.comwrote:
I have given the definition of lucky numbers and constraints involved at
the starting of the thread.
when a number's sum of digits and square of sum of digits is prime,it is
called lucky.
Just to clarify: do you
On Mon, Jan 23, 2012 at 11:42 AM, Marc Tompkins marc.tompk...@gmail.comwrote:
On Mon, Jan 23, 2012 at 10:51 AM, Shreesh bhat shreeshbha...@gmail.comwrote:
I have given the definition of lucky numbers and constraints involved at
the starting of the thread.
when a number's sum of digits and
No,i meant sum of digits is prime and also sum of square of digits is prime.
E.g: 23 is lucky cos
2+3=5 (prime)
2**2+3**2 = 4+9 = 13 (prime)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On 23/01/12 18:51, Shreesh bhat wrote:
Since i m new to Python.I dont know all its recipes and tricks inlvolved
to charm-the-snake.
So can i improve the islucky method more than what i mentioned before?
Not by enough to meet your constraints.
Just to be clear this has nothing to do with
On Mon, Jan 23, 2012 at 10:01:33PM +, Alan Gauld wrote:
Just to be clear this has nothing to do with Python. It doesn't matter
what programming language you choose there is not a PC on Earth that can
do what you want using the technique you are using in 16 seconds.
I don't believe that
Hi
On 23 January 2012 22:55, Steven D'Aprano st...@pearwood.info wrote:
Can i work around that way in python or should i come up with a new
algorithm?
You definitely need a fundamentally different algorithm.
I expect that this is some question from one of those annoying
websites that
On Mon, Jan 23, 2012 at 12:08 PM, Shreesh bhat shreeshbha...@gmail.comwrote:
No,i meant sum of digits is prime and also sum of square of digits is
prime.
E.g: 23 is lucky cos
2+3=5 (prime)
2**2+3**2 = 4+9 = 13 (prime)
Thanks for the clarification - or I should say correction, since sum of
On 01/23/2012 10:31 PM, Marc Tompkins wrote:
On Mon, Jan 23, 2012 at 12:08 PM, Shreesh bhatshreeshbha...@gmail.comwrote:
No,i meant sum of digits is prime and also sum of square of digits is
prime.
E.g: 23 is lucky cos
2+3=5 (prime)
2**2+3**2 = 4+9 = 13 (prime)
Thanks for the clarification
On Mon, Jan 23, 2012 at 8:03 PM, Dave Angel d...@davea.name wrote:
On 01/23/2012 10:31 PM, Marc Tompkins wrote:
On Mon, Jan 23, 2012 at 12:08 PM, Shreesh bhatshreeshbha...@gmail.com**
wrote:
No,i meant sum of digits is prime and also sum of square of digits is
prime.
E.g: 23 is lucky cos
On 01/23/2012 05:55 PM, Steven D'Aprano wrote:
On Mon, Jan 23, 2012 at 10:01:33PM +, Alan Gauld wrote:
Just to be clear this has nothing to do with Python. It doesn't matter
what programming language you choose there is not a PC on Earth that can
do what you want using the technique you
21 matches
Mail list logo