Ugly Numbers challenge from CodeEval