Solution to problem 1
Solution to problem 2