Screen Shot 2015-12-26 at 10.52.12 PM

Happy December, readers! Christmas has come and gone and you’re probably over it already. I, on the other hand, am determined to keep making progress on the Advent of Code challenge, which has served as a happy distraction and learning opportunity this month. When I haven’t been teaching, applying for jobs, getting prodded by doctors (long story), and trying to land my first contract gig, I’ve been helping Santa and his team deliver the goods.

In the process, I learned about (and/or got more practice using):

  • object-oriented programming (OOP)
  • string manipulation & regular expression matching
  • MD5 hash conversion
  • bitwise logic operators
  • arrays and hashes
  • functional programming
  • algorithmic efficiency (Big O notation)
  • and more!

Over time, I built out my repo to include testing (for easier code refactoring) and input files (for cleaner code), as well as a README detailing my approach to each problem. I know it sounds silly–and did not impress my career counselor–but this was truly a great professional learning exercise, and I’m enjoying the opportunity to see how other people solved the problems and how to optimize my own solutions. In some cases, my approach works, but takes a long time to run. In other solutions, my approach works in theory but takes too long to return a solution. I’m still tinkering and will read up on the problems I didn’t solve before I put it away until next year.

One of my favorite exercises was Day 14, Reindeer Games, in which a set of reindeer are racing, and the objective to to find how far the winning reindeer has travelled after a given number of seconds. Each reindeer travels at a set speed (x kms/second) for y seconds, and then needs to rest for z seconds. To solve this challenge I took an OOP approach and considered “what are the Nouns involved here?”

  • We have Reindeer, each flying on a track, organized by a race. Reindeer have a name, a distance they travel every second, a fly-time and a rest-time.
  • Each reindeer flies on a Track, which belongs to one reindeer. The track knows whether its reindeer is flying or resting at any given point, how long it has been in that state, and what index it’s at on the track (how far it’s gone). The track knows how to advance a reindeer once per second depending on the reindeer’s state.
  • Organizing all this we have a third class, Race, which registers the reindeer as racers and has a “run_race” method that advances each reindeer for a given number of seconds. At the end of the race, it checks each reindeer’s track position to see who has travelled the farthest, and returns a distance.

This is my favorite type of programming to do, as I enjoy thinking through the “who knows about / controls what” in a given problem set. My solution isn’t necessarily the most efficient (though I have no real reason to believe that it’s inefficient, besides having to carve out an array with ~5,000 entries for each reindeer to mark the “track” on which they travel), but it’s straightforward enough that a non-programmer should be able to look at it and basically understand what’s going on.

Well, see for yourself:

Fun, right?

Josh asked me if I could visualize the reindeer races and my answer was “haha, yes…” (though I’d do it in JavaScript probably). Let’s call those reindeer groundhogs and maybe I’ll do it for Groundhog’s Day.

Anyway, there are parts of looking for a development job that ask “what do you like / not like about programming?” and I never have a great answer, but I do like reindeer games. So, there’s that.

I updated The Plan with my January goals if anyone is interested. I can’t believe it’s been a year! This is my second January plotting out my own schedule. I’m really hopeful that I’ll find an opportunity that’s perfect for me to keep learning and contribute my new skills (& soon-ish, please), and excited to build some cool stuff and support some awesome students in the meantime. Being selected to work as a Teaching Assistant this month was an honor, and an experience I’ve really enjoyed. Helping others learn to code helps me internalize key concepts, and is immensely satisfying and rewarding. I’m glad I have the opportunity to keep doing it over the next few months with a new crop of students.

Happy new year to you and yours!