On 02/18/2013 03:54 PM, Ian Kelly wrote:
On Mon, Feb 18, 2013 at 12:13 PM, John Immarino <joh...@gmail.com> wrote:
I coded a Python solution for Problem #14 on the Project Euler website. I was
very surprised to find that it took 107 sec. to run even though it's a pretty
simple program. I also coded an equivalent solution for the problem in the old
MSDOS basic. (That's the 16 bit app of 1980s vintage.) It ran in 56 sec. Is
there a flaw in my coding, or is Python really this slow in this particular
application. MSDOS Basic usually runs at a snails pace compared to Python.
Well, I don't see anything that looks especially slow in that code,
but the algorithm that you're using is not very efficient. I rewrote
it using dynamic programming (details left as an exercise), which got
the runtime down to about 4 seconds.
Are you sure you wouldn't like to share with the class? I'd be interested
in seeing your approach...
--
----------------------------------------------------------------------------
Tim Daneliuk tun...@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list