solution to the Google Code Jam Practice 'Alien Language' problem