Solution to problem 12