Program for an algorithm class. Using brute force.