Gas station without pumps

2011 June 9

Project Euler as teaching tool

Filed under: Uncategorized — gasstationwithoutpumps @ 07:44
Tags: , , , , ,

In her blog Love2Learn, malyn writes in praise of Project Euler, coming to the conclusion “there is definitely room and reason for integrating programming in school and not necessarily as a separate subject/course.” I found her post through comments on John Burk’s post Project Euler vs Khan Academy: the future of online learning.  John Burk contrasts the challenging puzzle-like nature of the Project Euler questions with the dry-as-dust problems that Salman Khan uses as examples in the Khan Academy videos.  He contends that Project Euler is a much better pedagogical tool than Khan Academy.  I used the Project to help my son learn Python about a year ago (see my post Project Euler).

For those not familiar with it, Project Euler, is a series of math puzzles that can most easily be answered by writing short computer programs. The puzzles have been designed so that only about a minute of computer time is needed, but hand solutions without the aid of a computer are very tedious to do.  According to their home page, Project Euler started in 2001, and has now grown to a series of 341 problems.

Some people get a lot out of Project Euler. How I Failed, Failed, and Finally Succeeded at Learning How to Code by James Somers describes how he taught himself to program (after several failed attempts to learn from books) using Project Euler, and he draws some nice material from Lockhart’s Lament (about the poor way that math is taught).    Somers raises an interesting point

If programming is best learned in this playful, bottom-up way, why not everything else? Could there be a Project Euler for English or Biology?

Maybe. But I think it helps to recognize that programming is actually a very unusual activity. Two features in particular stick out.

The first is that it’s naturally addictive. Computers are really fast; even in the ’80s they were really fast. What that means is there is almost no time between changing your program and seeing the results. That short feedback loop is mentally very powerful. Every few minutes you get a little payoff—perhaps a small hit of dopamine—as you hack and tweak, hack and tweak, and see that your program is a little bit better, a little bit closer to what you had in mind.

The second feature, by contrast, is something that at first glance looks totally immaterial. It’s the simple fact that code is text.

His point is that the excitement of programming is difficult to duplicate in other subjects, where there are real-world skills or facts that need to be mastered.  I see this all the time in bioinformatics, where the biology is much messier than the algorithms and programming.  There is a lot more special-case and detail knowledge in biology, and a lot less reasoning and general-purpose tools.  A prediction made from a bioinformatic method may take 5 or 6 years of tedious wet-lab work to verify (or refute).

I agree that programming can be very addictive, but Project Euler has not, to my mind, quite captured that addiction for many people.  The attrition rate is too high for it to really be said to be addictive. In her blog, malyn says “I’ve only done a couple of problems on Project Euler.” I tried a few myself, and got bored after 5 or 6.  I kept meaning to go back and do some more, but I always found more interesting things to write programs about.  It seems that we are not alone—a lot of people start the series of problems, with 152,356 people having solved the first one, but very few stick with it for long, with only about 20,000 having gotten through 30 of the problems, and numbers around 500 once you get deep into the list of problems.

Somers also speaks in favor of the Project Euler forums, which you get access to after you have solved each problem:

Even if you’re not a programmer, it’s worth solving a Project Euler problem just to see what happens in these forums. What you’ll find there is something that educators, technologists and journalists have been talking about for decades. And for nine years it’s been quietly thriving on this site. It’s the global, distributed classroom, a nurturing community of self-motivated learners—old, young, from more than two hundred countries—all sharing in the pleasure of finding things out.

Of course, there are other such forums on the web that do not require solving problems to join. For example, the Arduino community  has forums at and that discuss how to use microprocessors (specifically the Arduino boards) to do all sorts of art and engineering projects.  The forums are a mix of people doing their first programming and expert computer engineers, all dedicated to making fun things that work using microprocessors.  Other hobbyist communities have similar forums for their enthusiasts.  Project Euler is unusual only in that the center of the hobby is math, which is more often associated with schooling that with hobbies, though recreational mathematics has a long and noble history.

I do think that teaching programming in grade schools and high schools is an important thing, and am quite distressed that my son’s high school has no computer programming classes: not even the pedagogically rather poor Java syntax course that would prepare students for the AP computer science test.  Putting math and programming together (as Project Euler does) serves to capture a few who are already heavily into recreational math or programming.  Putting physics and programming together (a recent meme for physics teacher blogs) may capture more students’ interests, and putting engineering and programming together (in robotics courses or clubs) may be even better.  I’m doing what I can by coaching a robotics club, but it would be good for programming to work its way into the standard high school curriculum.


  1. […] Project Euler as teaching tool ( […]

    Pingback by Challenge Students With A Puzzle « Eduhowto — 2011 June 9 @ 09:13 | Reply

  2. Speaking of physics and computing, are you aware of _Structure and Interpretation of Classical Mechanics_?

    Comment by plam — 2011 June 9 @ 10:38 | Reply

  3. […] the comments on my post on Project Euler, plam pointed me to a physics book: Structure and Interpretation of Classical Mechanicsby Gerald […]

    Pingback by Classical mechanics, with computer simulation « Gas station without pumps — 2011 June 9 @ 13:23 | Reply

  4. I made the mistake of giving a Project Euler problem to my high school beginning programming class as a project. I thought it was challenging and fun. They thought I was an idiot to do something like that for fun. Then I remembered, I am a Math geek, they were not. The average high school student does not do math problems for fun. Those that do are very different and are very rare. Is it possible to make someone excited about solving math puzzles? No more than it would take me to get excited about the classic art my 15 year old daughter gets excited about. There are much better ways of teaching programming that will interest high school kids. Compare “let’s write a program to solve a tricky math puzzle” to “let’s write a game”. Both will require the same basic programming skills but I think the second will capture a bit more interest from the students.

    Comment by Garth — 2011 June 10 @ 08:30 | Reply

    • I agree. The number of kids who are excited by math puzzles is relatively small. (My son likes them, but 10 Project Euler puzzles were enough for him.) When I’ve taught after-school clubs, I’ve gone more for games than math. Scratch is great for starting kids off.

      I’ve got to teach the robotics club programming this summer, starting with Python then C++ (though only enough C++ to program an Arduino, not the whole language). They have a clear goal in mind: building a user interface to control their robot from a laptop, so subsets of the languages are fine.

      Comment by gasstationwithoutpumps — 2011 June 10 @ 08:41 | Reply

      • I have been using the Lego Mindstorms robots for a couple of years. They work great from 5th grade to high school. I am not too crazy about the NXT-G graphical language that comes with the robot. It works fine for simple tasks but can be a real bugger passing variables. I have the high school kids use RobotC which is a C-based language with a number of built-ins designed for the robot. Using the robots is almost like cheating. The kids sort of get hooked.

        Comment by Garth — 2011 June 10 @ 09:29 | Reply

        • My son has played with the Lego RCX brick (the predecessor of the NXT). We found NQC (Not-quite-C) to be an adequate language (and it was free, unlike RobotC). But he never got very into the Lego robotics, other than reading the excellent book Building Robots With Lego Mindstorms: The Ultimate Tool for Mindstorms Maniacs, by Mario Ferrari, Giulio Ferrari, and Ralph Hempel. (They have a newer edition for the NXT now.)

          The high school robotics club is building an underwater remotely-operated vehicle, which they want to control electronically (that is, from a computer interface), so that their tether only needs one pair of power wires and light-weight control wires.

          Comment by gasstationwithoutpumps — 2011 June 10 @ 11:41 | Reply

  5. If I had been forced to learn computing via math puzzles, I never would have ended up with a computer science degree. I LIKE the structured nature of computer science – the object oriented stuff, thinking abstraction and modelling data, testing methods (I just spent a satisfying day figuring out how to write unit tests for a tricky Android service), and all that other stuff. As an undergrad, I loved operating systems – all those protocols! – and detested AI because we had to deal with silly puzzles all the time. My husband, also a software guy, loves those math puzzles. I wonder if it might be a gender thing?

    Comment by BKM — 2011 June 10 @ 14:13 | Reply

    • There may be gender differences, but they are probably not innate. Math puzzles seem about equally attractive to boys and girls in 5th grade (based on my tiny, non-scientific sample).

      Many of the “fun” things proposed for attracting people to computer science (robotics, math puzzles, game design, … ) have as big a gender imbalance at the high school and college level as computer science itself, so are unlikely to help change CS’s gender imbalance.

      Comment by gasstationwithoutpumps — 2011 June 10 @ 14:44 | Reply

      • “Many of the “fun” things proposed for attracting people to computer science (robotics, math puzzles, game design, … ) have as big a gender imbalance at the high school and college level as computer science itself, so are unlikely to help change CS’s gender imbalance.”

        That is because the people coming up with the “fun” things are all men…

        I majored in computer science back in the days when 30 to 40% of the majors were women. Yeah, I know, it seems amazing from today’s perspective. My summer job was in the application development department of a large university hospital, supporting a group of programmers – who were all women. I don’t think any of these women were attracted to the field by “fun” approaches. Rather, they got into it because in those days, it was seen as a stable, family-friendly career. This was long before PCs, dot-com bubbles, or geeks that hack all night. For me, the attraction was that I could DESIGN things that would be useful. I didn’t want to be in the sciences because that meant studying things that already exist. I wanted to design and build new things.

        I think we have lost sight of the fact that computer science is an engineering field in which people design systems that allow useful things to happen. I wonder, if we somehow could allow students to design and build useful systems early on – I mean really useful – for example, phone apps that let people in third world systems track information – maybe we would attract and retain more women.

        Comment by BKM — 2011 June 10 @ 16:37 | Reply

        • This makes me curious about historical trends in male/female computer scientists. My mom (since passed away) did FORTRAN programming at Lawrence Lab from about 1959-1965. She had most of a masters in astronomy. She stopped working when I was born. When I did some programming in high school (16K of memory and a tape drive), she wondered where the room with the “rest” of the computer was. I never thought to ask her if there were other female programmers whom she worked with. I guess I figured they were mainly men, since that’s my experience working with programmers as a technical writer — though anecdotally I think it’s getting a bit better over the years.

          Comment by Yves — 2011 June 11 @ 18:03 | Reply

    • I have a computer science degree too and I am the total opposite of you – I hate operating systems stuff, anything to do with hardware, etc. and love the puzzle-like part. I’m male, so maybe it is a gender thing. Probably not, though.

      Comment by Jonas — 2012 July 23 @ 02:33 | Reply

  6. Thanks for posting again about Project Euler. I pointed my son to it Thursday evening, and he’s solved 8 or 9 problems in Python so far (most using a netbook while we took a short road trip). He’ll probably slow down Monday when he starts the AoPS Python class. Perhaps it is gender specific, because while I know enough programming to help troubleshoot his syntax errors, I’m not really tempted to solve the problems myself. After reading the comments here, he says it works for him because he’s both a Math Geek and a Computer Geek.

    Comment by Yves — 2011 June 11 @ 17:54 | Reply

  7. I have never heard of the project euler as a learning tool.I will be looking into it.

    Comment by Michael Bates — 2011 September 8 @ 20:43 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: