Solution for code eval problem ugly numbers