solution for chapter 1 exercise 4