Project Euler

Since starting my “code everyday” discipline, one of the problems has been to have a bite-sized objective to focus on; one that I can pick up, think about in a short session, and then code.  The point is to hone my problem solving skills, as well as the specifics of coding in whatever language. Sometimes you just can’t think of a suitable topic, without getting bogged down in a larger project (which defeats the point of code everyday.)confused-kid-looking-at-math-problem-Getty-Images
Thanks to Treehouse’s tweet about this post listing helpful tools to practise coding and problem solving, I found Project Euler, a large and growing set of mathematical challenges to solve with code. It is a very simple site, but tough and unforgiving in terms of the challenges themselves. You get a statement about a mathematic problem, maybe with an example, and then a specific challenge to solve in code. There are no shortcuts, no clues, just a very simple statement of a mathematical challenge and a blank space to put answer. The FAQ’s encourage you to research the techniques, but heavily discourage you and others to post specific answers or clues to the problems. It may take days to work out how to solve the problem, and an hour to code it, but you are encouraged to write code that executes in under a minute. This makes you think about code efficiency. Especially as some of the problems require many nested loops, and hundreds of digits to be handled. Suffice it to say you are going to have to think outside the box of standard integer, long or double data types to get many of the answers. That said, the simplest logical solution for implementing can sometimes be inefficient, and a little research may reveal mathematical shortcuts to save a few million iterations of a loop.

The point is, I have found these challenges to be great exercise, and perfectly suited to my code everyday. If my aim is to learn coding, then why divert brain power onto mathematics? Maths is the semantics of code. There are few problems you can solve in code without doing a bit of pencil chewing over some aspects of maths, even if that’s just controlling your loops. For some I have written code and got the answer in 15 minutes, others have taken a few sessions over 4 days, and lots of scribbling and sketching on paper to understand the maths. One has me beaten altogether so far, excluding those I have not dared start. I think I have code that gets the answer but Euler says no. And there is a very simple statement on the site.

Please do not contact Project Euler if you are unable to solve a particular problem. If you can’t solve it, then you can’t solve it!

Infuriating but there you have it. The gauntlet is down. Once you have solved it you get access to a forum where people discuss their approach and even post code snippets.
After one month I am one problem short of my first 25 problem milestone.

No comments yet.

Leave a Reply

Powered by WordPress. Designed by Woo Themes