problem 39 solution