Added solution for problem 6.