Monday, June 13, 2011

Project Euler

Following a pointer from my mother (yes, indeed!), I've been reading through a fascinating article by James Somers: How I Failed, Failed, and Finally Succeeded at Learning How to Code published at The Atlantic's web site.

In the article Somers discusses his own personal history about learning how to program, and describes some of his early attempts at learning to program by reading programming books:

I imagined myself working montage-like through the book, smoothly accruing expertise one chapter at a time.

What happened instead is that I burned out after a week. The text itself was dense and unsmiling; the exercises were difficult. It was quite possibly the least fun I've ever had with a book, or, for that matter, with anything at all. I dropped it as quickly as I had picked it up.

I've read those books, plenty of them, and they are "dense and unsmiling" indeed. Mr. Somers, I feel your pain!

But then Somers got lucky, and stumbled onto an early version of Colin Hughes's wonderful website, Project Euler.

Somers goes on to describe the effect upon somebody who has an aptitude for programming, when they encounter the Project Euler problem set:

What's especially neat about it is that someone who has never programmed -- someone who doesn't even know what a program is -- can learn to write code that solves this problem in less than three hours. I've seen it happen. All it takes is a little hunger. You just have to want the answer.

It's a very insightful description, and quite accurate, I suspect. If you are a natural programmer, then looking at the problems on the Project Euler website will have an immediate effect on you. As soon as you see Problem 1, written almost a decade ago but still just as fresh now as it will be 100 years from now, you aren't going to be able to think about anything else until you go find a computer somewhere close to hand and bash it out:

# include <stdio.h>

int main( int argc, char *argv[] )
int answer = 0;
for (int i = 1; i < 1000; i++)
if( i%3 == 0 || i%5 == 0 )
answer += i;

printf("Answer to Project Euler problem 1: %d\n", answer);
return 0;

Now, there's no magic here. Programming is hard work, and, like any well-developed skill, it takes practice, practice, and yet more practice (take it away, Abstruse Goose!) Puzzle-solving techniques like these can help you stay motivated, and can help you progress from the simple to the more complex, but it's up to you to persevere, and to sweat the details.

But as Somers notes, this is what learning should be like, and this is what the Web is supposed to be all about:

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.

I heartily concur.

So thanks, Mom, for sending me the link, and thanks Colin Hughes for the fascinating website, and thanks James Somers for the thoughtful essay.

Now I'm off to work on that next problem...

No comments:

Post a Comment