#12 Solver for problem 30