So, after several months, grabbing an hour here and there in between work and parenting I've somehow managed to reach Level 4 in Project Euler. For anyone who doesn't know what that means, it means I've passed beyond the first 100 "public" questions, and have entered the "hidden" questions.

The first 100 problems on Project Euler are up for open discussion. You can post thoughts, solutions, methods, anything. It's encouraged not to look at other people's solutions online, but there's nothing to stop you doing it. Once you pass #100 you promise that you won't share any more information about the problems, which means that not only do the problems get tougher, but it's much harder to find clues and hints online.

During the first 100 problems I've had a good chance to look at the problems from the perspective of someone who's so-so at maths, but marginally better at programming. The problems are, indeed, very maths-focussed, almost entirely so. In the first 100 problems there are, perhaps five problems which serve a useful purpose to the general coding community, whereas the rest are esoteric curiosities which may be of use to maths graduates or when attempting to solve more unusual problems.

Each of the problems needs the solver to think laterally. Sometimes you need to just sit with a pencil and paper and puzzle it out, whereas in other cases you either know the way to solve it, or you don't. One of the puzzles which comes to mind uses "Pell's Equation", which is effectively a way of finding x and y when the equation is of the form x^2 + Dy^2 = 1 (or -1). Looking for this solution is hard because unless you know its name, you'll never find it. I stumbled across it because I ended up looking for a clue. Mathblog has lots of useful methods to solve Project Euler problems, and I searched for a solution to do with finding solutions to bivariate quadratic equations.

Now, you have to understand that I've never been a grade-A maths student. Yeah, I'm fair at it, but I got a 'B' at A-level and I kinda feel that whoever marked my exam paper must have been feeling generous that day. I have a good feeling for numbers and can puzzle my way through a lot of stuff, but intuiting that something of the form aX^2 + by^2 + cxy + dx + ey + f = 0 can be reduced to something with a name I'd never heard, and solved using a process I'd never been taught is a wee bit beyond me.

That puzzle was the first time I felt a bit 'cheated'. It wasn't one that you could just sit down and figure out, you needed to know the name of the thing to solve it, which was a bit of a kick in the penis if you ask me. It turns out that many of the puzzles in the first 100 are inspired by stuff that Leonhard Euler did in his career, so a scan of his corpus of work might have led me to them as well, but to say he did a lot is an understatement. His back-catalogue of theorems, derivations, lemmas, axioms, functions, calculations and proofs could fill multiple books!

So, as I got closer to the end of the first 100, things started to go slower and slower as the maths required to solve them became more and more esoteric. After one problem up in the 90's I really questioned whether there was any point going on. It was taking me a good day of puzzling during free moments, many pages and several hours of research. Infuriatingly, I'd find a relatively good solution, pass the puzzle to find that if I'd only known of.. I dunno.. Zemeckis Derived semi-aquatic hyper-cyclic number groups, I could have solved it in five lines of Python.

So, I was very close to giving up when one of the last problems was Sudoku. Finally, a real-world problem I could get my teeth into. I spent a good day writing a solver, tweaking and fixing it... And finally it worked. I looked at the thread and found that many had ignored the 1-minute guidance and written a brute-force solver that just tried every permutation until one 'stuck' . Great. Then I realised that most of the Python solutions just used numpy, avoiding the need to actually code anything.

At this point I gave up writing my own array-based arbitrary precision integers and just started using the inbuilt BigInteger library in C#.. Then I finally threw in the towel and started using a linear algebra library. Now that I've succumbed to the dark side, and will just use all the inbuilt or pre-built tools I can find... I'm hoping the next 100 will pass by a lot quicker than the last 100, where I puzzled through and built everything myself :)

Previous Post Next Post