#2 Solver for problem 19