Added solution for exercise2.