Last night I participated in Round 1 of the 2009 Google Code Jam. I thought all of the questions were difficult, but I squeaked by and advanced to Round 2.
I first worked on the Multi-base happiness problem. I had never heard of happy numbers before, and wasn’t sure how to determine that a number was unhappy. How many times should I iterate summing the squares before stopping? Fortunately Wikipedia told me the remarkable property that the iterations either reduce to 1 or enter a cycle. The other key to this problem is memoization.
I skipped Crossing the Road and tackled the Collecting Cards problem. I first coded up a simulation. This failed to generate results with sufficient precision. I actually succeeded in coding up an alternate solution, but I didn’t submit it in time. My solution walks down the expectation calculation, passing along the conditional probability of reaching each point. This works fine, but I feel there must exist a super clean solution for this problem.
In any case, I was fortunate enough to pass on to the next round, where I’ll surely be destroyed.