Added solution for exercise 4.