Working copy of Problem 12. Too inefficient to solve.