solution for exercise 15.42 (b)