Refactors problem 11 solution.