#7 Solver for problem 25