Google Code Jam Practice Excercise B