solve exercise 22.18