blunt essays with sharp points
Apr 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 Dĳkstra 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!
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