[Tutor] OverflowError in lucky numbers script
Steven D'Aprano
steve at pearwood.info
Mon Jan 23 23:55:50 CET 2012
On Mon, Jan 23, 2012 at 10:01:33PM +0000, 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 you could do it with the fastest supercomputer on
earth. If you have to test 10**18 numbers in 16/10**5 seconds, that
gives you less than 0.0000000000002 nanoseconds per test.
This isn't a question of tweaking the code to make it run faster, you
need a fundamentally different approach to the problem, as Alan says.
Either that, or we have completely misunderstood the constraints of the
puzzle.
> >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 offer extremely advanced mathematics puzzles disguised as
a programming challenge. (Well I find them annoying. The answer almost
always turns out to be something which took a genius of the level of
Euler or Gauss to discover, and they expect you to come up with the
answer on your own.)
--
Steven
More information about the Tutor
mailing list