solved problem 39