Project Euler

Posted on September 17, 2007 by Steve

It is positively cheering to see that tens of thousands of man-hours (and undoubtedly some number of woman-hours) are being invested in Project Euler. I have solved five of the easiest problems so far, and am pleased to report that all of my programs run in less than the minute said to be sufficient. Writing the programs is another matter; I didn't expect to find so much challenge and subtlety in writing a simple prime number validator.

I am using this as an exercise to learn some Python in addition to sharpening my number theory; other people take a more traditional approach.
« Prev itemNext item »


Posted by RWH | September 17, 2007 | 21:19:04

At the risk of seeming derivative, I chose to emulate your use of PE as a python training exercise. I was (only) moderately surprised that my first stab at problem 1 got the right answer on the first swing. Lessons learned in this exercise:

*Python does not have the ++ operator.
*Significant whitespace is the most moronic concept ever.

Posted by Steve | September 17, 2007 | 21:33:49

I noticed that one has to be logged in to see your profile.

The first time I needed to increment something, I used "+= 1" then I thought that looked lame so I changed it to "++". Then I changed it back.

I feel a little guilty about #5. My "program" was a nineteen-line comment and then a "print" statement with the answer. It seems far more tedious to write an algorithm for the general case.


Posted by Tony | September 18, 2007 | 10:18:28

Excellent idea, Steve! Now how about showing us some code?

Posted by Tony | September 18, 2007 | 10:20:05

Drat -- how about some normal HTML in this blasted thing?!?! And a preview function for comments?

This is what I was trying to link to.

Posted by RWH | September 19, 2007 | 10:44:24

I have set up some web space on fiat to share and compare code. I couldn't find a good, simple content management system to arrange the files, so I just went low-tech: contains subdirectories rwhunley and wasoxygen, each of which will contain files with our respective solutions. Anyone else who wants to participate, if you post your PE username here I'll create space for you as well.

The file names will have the format problemXXX_[ANSWER].txt, where XXX is the three digit problem number (i.e. with leading zeroes), and [ANSWER] is the numeric answer.

E.g. if the answer to problem 1 is 1111, my solution would be at

I was tempted to go back and edit some of my early floundering, but leaving it in will have definite entertainment value.

Posted by Tony | September 19, 2007 | 11:00:41

I am on PE as dionysus. Can I join in the fun? I'm way behind on the pace of the solutions, but hey, at least they are in Ruby :)


Posted by RWH | September 19, 2007 | 11:13:02

Great - more the merrier. I set up an ftp account with uid (my hosting company's ftp account setup is quirky - you'll need to use that whole string, including the, as the user ID). I'll send the password to the hecat guy to forward to you.

Leave comment

You must be logged in as a member to add comment to this blog