#8 Solver for problem 26