Solution to problem 1