solution for problem 29