Problem 012 rewritten