HP CodeWars challenge #2