Semi-completed problem 14, except for memory exception.