Scrupuli
blunt essays with sharp points
I have been attacking the problems at Project Euler.net
by ScrvpvlvsApr 26, 2011 6:30 PM–… and Project Euler is winning Round 34.
I have been working my way through some fun problems at Project Euler.net. Fun for me, anyway. To solve them takes what Edsger Dijkstra called mathematical engineering: mathematics and programming skills used together.
There are many problems to choose from, from very easy to very challenging. But they all have this in common: though it takes time and thought to analyze each problem, the solution should run on any basic computer in less than a minute.
Which is great! It means that nobody needs a supercomputer to solve these problems: just a PC and the will to learn and succeed.
Which brings me to Problem 34,
find the sum of all numbers which are equal to the sum of the factorial of
their digits.
This problem is eating my lunch.
My solutions to problems 1–33 were sometimes lazy. Yes, some run under a millisecond, or scale to much bigger problems than those posed … but I have also been perfectly satisfied with brute force solutions if they ran under a minute on my old PC.
But, so far, my solution to Problem 34 takes more than 2 minutes to run and its output is rejected by Project Euler for no good reason that I can see. Suddenly I cannot afford to be lazy.
Incidentally, all my solutions are written in Perl. I have, as I hoped, learned quite a bit about optimizing Perl programs that I did not know before.
In case you can’t tell, I am really enjoying this!
Labels: brute force, Dijkstra, Dijkstra, mathematical engineering, mathematics, optimizing, Perl, programming, Project Euler
Share: Tweet
1 Comments:
by Keverdy13
July 01, 2011 12:11 AM–Woa! That is so cool! Thanks for sharing. I am so subscribing. And thanks for recommending Perl.
about.me
Follow
vs.
Recent Articles
Do it yourself repair of a Panasonic KX-FL511 fax ...
Google Chrome On Track To Overtake Firefox
Do not cede moral high ground to Pope
Geminid meteor shower TONIGHT: predicted to be bes...
New buttons and options being tested in Google Maps
Faith Is Not A Renunciation Of Evidence
Manic And Depressed All At Once? That’s Normal
Make Firefox Take Geolocation From Google Latitude
Archives
November 1999June 2000
July 2000
September 2001
October 2001
February 2002
March 2002
June 2003
February 2004
June 2004
July 2004
August 2004
September 2004
February 2005
March 2005
November 2005
July 2007
March 2008
April 2008
May 2008
October 2008
November 2008
December 2008
January 2009
April 2009
September 2009
December 2009
February 2010
March 2010
May 2010
June 2010
September 2010
October 2010
November 2010
December 2010
January 2011
April 2011
June 2011
July 2011
August 2011
September 2011
December 2011
February 2012
April 2012
May 2012
June 2012
July 2012
August 2012
September 2012
November 2012
January 2013
February 2013
April 2013
February 2014
May 2014
October 2014
June 2017
February 2019
Finish each day and be done with it. You have done what you could. Tomorrow is a new day; begin it well and serenely and with too high a spirit to be encumbered with your old nonsense. —Ralph Waldo Emerson
Sometimes they fool you by walking upright.
What part of “Ph’nglui mglw’nafh Cthulhu R’lyeh wgah’nagl fhtagn” don’t you understand?
Build a man a fire, and he’ll be warm for a day. Set a man on fire, and he’ll be warm for the rest of his life. —Terry Pratchett
Never try to teach a pig to sing; it wastes your time and it annoys the pig. —Robert Heinlein
Do not ask why the past was better than the present, for this is not a question prompted by wisdom. —Ecclesiastes 7:10
Power lines abruptly stopped causing cancer in 1997 after the U.S. National Cancer Institute conducted a better study. —Robert Parks
Встретимся под столом! (Vstretimsja pod stolom: To meeting you under the table!)
The more you cry, the less you’ll pee.
Relish the love of a good woman.
It’ll never get better if you keep picking at it. —advice from Judge “Maximum” Bob Gibbs