Added solution for exercise 3.