As always, you can find my source code at CodePlex.
Problem 11 has given me all kinds of trouble. So much so that I haven’t actually solved it. I’ve tried 2 or 3 different methods, I’ve Google it, I’ve tried cheating, I’ve tried guessing. Nothing is working for me. I gave up after many, many tries. I’m so sure that I’m doing it right, but I must be missing one minor thing somewhere.
Problem 12 was kinda fun. The meat of the problem is figuring out the factors of a given number. Once I had that (which was easy to brute force, and a little tricky to slim down), the rest is just a couple of for-loops. I used the given example as a single test case.
Problem 13 involves very, very large numbers. Larger than 32-bits can represent. So, since I was still using .NET 3.5 at the time, I scratched out a very rudimentary “BigInt” class that only performed addition on itself. It was just as much a pain in the neck as it was 10 years in Introduction to C++ class, except this time I only implemented one operator. Once I switched the Project Euler solution over to VS2010 and .NET 4, I went back and switched this solution to use the BigInteger class, which, by the way, is new to .NET (obviously) and lives in System.Numerics. Anyway, once you have your own BigInt or BigInteger (or some language like Ruby that handles all that nonsense for you), Problem 13 is a piece of cake: just do some adding up and some parsing. I wrote a couple of tests that used long.MaxValue—I left them in, even though it’s generally quite silly to test a class built into the framework.
If you guys have any ideas for Problem 11, I would love a fresh set of eyes.
