February 27, 2014
Practicing with Project Euler

My Project Euler Badge

My Project Euler Badge

I’ve recently solved my 25th Project Euler problem, progressing to level 1!

For those who might not know, Project Euler is a site which provides a large collection of problems designed to be solved with a program. Many of the top problem solvers list pencil and paper as their programming language, however. Euler problems are designed to be solvable in less than a minute. While many can be solved by brute force, most will need a more well-thought out approach to solve them within a reasonable time frame.

Project Euler has been on my radar for awhile now, but I’ve only recently started working on it. It’s proving a great way to practice and learn new languages. I’ve primarily been solving problems with Haskell, but I also have several solutions in Common Lisp and Racket. Haskell seems especially well-suited for many of the puzzles on Euler. Dealing with infinite streams is a common theme and Haskell’s lazy evaluation shines there. It’s not uncommon to set up the problem in the most obvious way, then let laziness ensure that you don’t do any more work than necessary. Though I’d love to give an example of this, Project Euler discourages sharing solutions online so as not to spoil anyone’s “Ah Ha!” moment.

If you’re looking for a way to practice your skills or learn new languages, I highly recommend giving Project Euler a look. Or if you want something a bit less mathy, check out Code Wars. Unlike Project Euler, it’s not language agnostic: they currently support Ruby, JavaScript and CoffeeScript. Support is also on the way for Python, Haskell, C# and Java. Unlike Euler, Code Wars also has a big focus on TDD which might be a plus for some people.