Solution code for problem 2
Solution code for problem 3