Adding solution for Problem 7