Add solution for exercise 4 of chapter 8.