Refactor solution to problem 18 using .max method.