Project Euler

Ran across a short weblog entry on Leonhard Euler, the father of functions and initiator of much in the way of number theory. The mention of Project Euler caught my eye, as I rather like projects that involve multiple PLs attacking the same sets of problems.

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems. The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.
Project Euler has been around for almost as long as LtU but this is the first I'd heard of it. I find the questions and the competitive gaming aspect to be interesting, though I have a long way to go (level 2 out 5). Not sure there is a direct tie into PLs, but since I'm using it to learn more math and investigate the breaking points and elegance of PLs... and anything involving multiple PLs in competition and mathematics can't be too far removed... and since I haven't posted a story to LtU in a while and this happens to be my current interest... well, that will have to suffice. I'll have to admit though that many of the solutions I looked at are either too rushed (brute force), too cumbersome (indexes flying everywhere) or too terse. But that's true of most code that I run across (including my own). Still hoping for a PL that has that just right aspect - though I'm leaning to Oz these days.

(For those of us that are looking for walk-through/cheat guides, the Haskell wiki has the code to the first 200 problems, and I've put my Oz code for the first 50 up on the CTM wiki).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

PE Popular w/ Clojure Newcomers

I've noticed that attempts to solve Project Euler problems seem to be popular among people learning Clojure.

Not just Clojure

I'm sure that's true, and I've noticed the same thing with Scala and in #haskell. From what I've heard, it's a lot of fun and fairly challenging.

XSLT, too

I have been member of Project Euler since 17 Jan. 2009 and have solved 36 problems till now.

Probably half of these could be solved just using a pen and paper or a simple calculator. For all the rest I have used XSLT (plus the FXSL library and the Saxon XSLT 2.0 Basic processor.

It is natural and convenient to use XSLT 2.0 + FXSL for number crunching. The resulting code is quite short and self-explanatory.

I will start publishing my XSLT solutions to some of the older problems -- not to spoil the pleasure of the numerous participants of finding solutions to the new problems by themselves -- on my blog.

Smoke testing; Haskell Wiki

Aye, PE is a lot of fun. I found out about it on Jul 1, 2008, and solved 52 problems within 36 hours, representing about 16-20 hours of work, or about 20±2 minutes per problem on average.

I could have kept more careful track of my initial performance, but I did keep some notes, as the early problems are pretty easy and straightforward and I was curious how I'd do. I haven't really kept many notes since then, though.

I'm now closing in on level 4 but haven't been working on it very much lately. I have certainly learned about or improved my knowledge of several rather useful techniques and algorithms as a result of the site.

One downside with the PE mentality is that just because you got the answer correct doesn't mean your program is correct or even good. Many of the problems on PE are of a type where this isn't a huge problem in practice. However, it's especially noticable with Problem 54.

Most of the solutions posted in the forum (accessible after you've solved the problem) are decidedly incorrect. However, they tend to mess up in corner cases that are rather unlikely to occur in 1000 randomly generated pairs of poker hands. (e.g. both hands are two pairs, but the faces on the pairs are the same, so the winner is determined by the non-pair card in each hand.) Of course, this mentality is hardly unique to Project Euler.

The wiki for Project Euler on is controversial; reading the discussion pages and browsing the histories can be mildly entertaining. I've found it occasionally interesting to compare my solution to the wiki solution. However, many solutions are missing, or of mediocre to poor quality. A few don't even produce the correct answer for the given problem instance.

In all, I tend to agree with the Project Euler team's sentiments; I have many solutions I could contribute to the Haskell Wiki but won't. I did contribute one solution I was pleased with, but only because I couldn't post to the official problem forum because it was locked, and there was nothing quite like it already in the forum.

I did find one of my math buddies from High School who I hadn't heard from in a few years on Project Euler. I've been trying to convince him to learn Haskell, as he is "not much of a programmer" and I think it would appeal to his sensibilities.

That's the beauty of Project Euler, compared to most (e.g. ACM) programming contests. Instead of having to select from a rather narrow list of prescribed languages and tools, you can pick whatever tool(s) suit your fancy at that moment and focus purely on problem solving.

Computer scientists and programmers certainly can get too focused on tools at the expense of problem solving, and I think Project Euler offers a nice antidote to the traditional programming contest in this regard.

I did a handful of the PE

I did a handful of the PE problems, and they are pretty fun, but Chris is right to assume they aren't really tied to programming languages, quite a few people list "Pencil & Paper" as their tools.

Also, I wasn't too fond of their "forum", because
1) now there are like 50 pages for each task (at least the easier ones).
2) it's hard to find your own post, or follow any discussion.
3) when I first started the forums were pretty plain, but then they started AJAXing them all up and really screwed them up. Might have fixed this now however.

I know that I could be far

I know that I could be far more adept at solving PE problems with pencil and paper alone, but I don't think you can honestly get very far without writing a few programs.

I can see your complaints about the forum. I guess it hasn't bothered me too much, but something better would be nice from time to time. The forums are the most interesting while a problem is new and the associated forum is still fresh. For many problems the first few pages cover the solutions worth knowing. There, of course, are exceptions.

The community has it's quirks, and the website it's based around has it's limitations, but the same is true of LtU. :-)

[edit: By the way, the forums do use some simple Javascript, but no AJAX that I'm aware of.]

Indeed, it looks like they

Indeed, it looks like they fixed the forums a little, also they now have syntax highlighting, so that's a little nicer.