Google code jam 2008: A and B Rounds: solutions