Python solution for problem 2
Python solution for problem 3