Problem description: https://www.codeeval.com/open_challenges/17