Extremely inefficient way of solving problem 10.