Working solution for codekata #2 (1 of 5)