Solution to a simple 'hacker rank' puzzle.