Add solution to Exercise 3.1.