Tips for the Google Code Jam Programming Contest

This year I decided to compete in Google Code Jam. I thought it would challenge my knowledge of algorithms and complexity classes, or my ability to write code cleanly or quickly leveraging the IDE. Nope, not even close. I quickly learned the so-called coding competition is really a problem-reading competition. Here are the top lessons I took away:
  1. Pay attention to detail. Often times, I would think I understood the problem and only after coming up with a failing solution would I realize I skimmed over one sentence that changes the nature of the solution entirely. Do not give in to pressure and skim over lines. The contest tests your ability to understand a word problem completely and solve it with an algorithm, not how fast you can code.
  2. You don’t need fancy languages, libraries, or IDEs. I made the mistake of trying to solve a constraint-based problem in Prolog which I hadn’t touched for 3 years and ended up wasting half an hour. You do not need objects, lambdas, or magical libraries. All you need are ints, doubles, and if-thens and for-loops.
  3. You don’t get points for cleanliness. Unlike a real project where things like well-named variables and refactored functions matter, all the top contests use single-letter variables and their code reads like spaghetti. 
  4. Use a template for reading and writing the files. All the input and output files are in a standard format you should just copy and paste between problems. I wasted several minutes during the first round trying to get my input and output correct.
  5. Practice, practice, practice. I took the Code Jam for fun this year so I didn’t prepare and was happy to place 2,000 out of 17,000. But I realized if a lot of this boils down to practice. And practicing problems will make you a better programmer. Next year I plan on making it to Round 3 and hopefully the finals. I’m coming for you Code-Jam T-Shirt! 

No comments:

Post a Comment