Refactored problem 14 to run in less than 1 second.