Solved problem 5 using brute force.