Solution to http://zeroturnaround.com/fun/magical-java-puzzle-pat-the-unicorns/