jump to navigation

Project Euler June 24, 2008

Posted by blueapple in Other, Programming.
trackback

I’ll have to admit it, Project Euler has got me hooked for the last few weeks. It all started with a friend asking me for help regarding a math problem. It didn’t take long before we had figured it out, but I was interested where he got it from, as it involved writing a program to generate the solution.

Project Euler, he said.

To summarize the whole thing: It is a website which presents various (At the time, 199) math/programming problems. Once you have submitted the correct answer, you’ll be given access to a forum thread where people post their solutions and thoughts about the problem. In some cases, there is even a pdf-file explaining the problem (and how to solve it efficiently). You’ll be amazed how some people solve the problems. Me sitting there, proud of my 100 lines of code and seeing a solution in two lines that generates the solution five times as fast. But one learns a lot.

I saw this as an opportunity to learn Haskell too.

Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry.

Wikipedia: Haskell (programming language)

It is quite different from C++ (or any imperative programming language). But not different in a bad way. One of the cool things with it is what is called “lazy evaluation”. It allows one to declare something which is not computed until it is needed. So you can declare a list of all primes, or a list of the whole Fibonacci sequence (which is infinite). And then, the element you want will be computed only when you need it.

Now, I’m still a beginner with Haskell. But I’m learning more each problem I solve. I would recommend using Project Euler either as a tool to learn a new programming language or just to give you exercise with one you know. It’s a fun challenge, can you make it to100%?

Comments»

1. Brent - June 24, 2008

Hi there, glad you’re having fun with Haskell and Project Euler. PE is indeed a great way to learn a new language! If you haven’t already, I suggest dropping by the #haskell IRC channel on freenode.net — it’s a fun and friendly place full of lots of people who love answering questions, a great place to hang out if you’re learning the language.

2. Jeremy D. Frens - June 27, 2008

I’ve been doing something similar myself, although I’m trying out five different languages. (It would be six if I could get a working Dylan compiler.) And I’m blogging the whole thing: http://jdfrens.blogspot.com/search/label/project%20euler .

3. Douglas M. Auclair - June 28, 2008

@Jeremy, what do you mean by “working Dylan compiler”? I suppose you’ve been to http://opendylan.org, yes? What’s your architecture? (Apple? PC? Linux? Darwin? Windows? Solaris? IRIX? PPC? SPARC? x86?) It’s been a while since I’ve worked on Dylan, but I’ve had it run on all those configurations before, including Harlequin Dylan, Marlais, and Gwydion Dylan. If you’d like to take this off-line, my email is doug@cotilliongroup.com.


Leave a comment