prob_10 solve but need to be faster