Solved problem 9 by brute force.