Initial brute force attempt for Problem 41