Solution to problem 12 completed