A couple weeks ago, Nat Torkington, on the O'Reilly Radar blog,
about Project Euler.
"Project Euler is a series of challenging mathematical/computer
programming problems that will require more than just mathematical
insights to solve. Although mathematics will help you arrive at
elegant and efficient methods, the use of a computer and programming
skills will be required to solve most problems."
I love puzzles. It's probably why I enjoy programming and debugging
software so much. These particular problems are a delight. They are
simple to understand and require thought. I will admit I've only tried
(and solved) the first thirteen so far (I haven't even made it
to level 1) and so have a long way to go, but there's nothing here that
leaves me wanting to tear out my hair in frustration.
You certainly can use brute force to get to the answer, but usually
with a little thought, you can find a short cut. So far my longest solution
took 28 seconds (on an intel Dual Core laptop). Nearly all of the rest
have taken much less that 1/10th of a second. As with a lot of
software related problems, finding the right way to represent the
initial data is half the solution.
Now I can just hear some of you out there saying, why on earth would
you want to do something like this? Don't you have enough RealWork(TM)
to do? There are a few reasons. The first one is to see if I can find
that elegant solution. I've also been doing these problems in Python,
the language I use for most programming work nowadays, and after I've
found the solution, I'll look at the posts in the forum related to this
puzzle, to see how other Python programmers have solved it. In that way,
I often find out things about the language that I didn't know. This
accumulated knowledge then makes it easier to solve the next puzzles and
(hopefully) improves the Python code I write for a living.
But one of the main reasons is to try to remind myself of all that
math that I'd forgotten. My son's math homework is not yet at a level
that's beyond me currently, but it won't be that way for ever. I need
to take a quick refresher course, and this is a fun way of doing just that.
[Technorati Tag: Project Euler]
[Technorati Tag: Puzzles]
[Technorati Tag: Mathematics]