Friday, January 11, 2013

Math

As I mentioned in a previous post, I have re-discovered the joy of math. I have been using Project Euler to refresh and improve my Perl knowledge to help with my new role at work and have worked my way through a few dozen of the problems. I am not ashamed to admit that I am finding it quite fascinating, and very much enjoying it.

The problems cover a fairly wide range, from some combinatorics issues (counting paths in a grid, finding permutations) to number theory (factorization, many problems related to primes.) Thus far they have been fairly easily defined and haven't required any crazy math (i.e. calculus.) That said, as the problems have gotten more complex I have found myself doing some wikipedia research into the underlying concepts. This is great, since I have been interested in number theory (and numerical analysis) for a while but never actually found a reason to dig into it much. I am a huge nerd. He said in a post on a blog about programming about math.

As I have worked through these, I have definitely gotten better at Perl. I still don't love a lot of the choices they made but at least I am learning how to use the more advanced concepts. I've built complex data structures with references (god forbid a language provide multidimensional arrays without making you go through flaming hoops) and even built my first Perl object, which handles arithmetic on arbitrarily large integers. Perl's objects are weird, and carry through the general frat party abandon of the rest of the language. There are no access levels (private, protected) and a lot of the fundamentals of OO seem to exist purely by convention. It's very odd, and very Perl.

Once you solve a problem, a forum is unlocked in which you can discuss that problem. It's common for folks to post their solutions there, and looking over some of the designs can be very enlightening. For every awful brute force approach or esoteric language I have never hear of, there are some very clever analyses that can really expand your knowledge. It also strikes me how often folks 'cheat' in their implementations. For example, if a problem has you summing one hundred fifty-digit numbers and you use a library function that does it in one line, what's the point? Since I am in this at least in part to dig into the math, it just feels like cheating at solitaire to me. I suppose everyone is in it for something different.

While I may not make it through all 409 (and growing!) problems, I do think I will keep going for a bit. After all, I have to finish my sweet sieve of Eratosthenes that can dynamically grow when larger numbers are requested.

No comments: