problem 31 solution