Solution to Google Code Jam Practice Question.