Solution to Google Code Jam questions in python