Optimizing Problem 5. It still takes longer than I would like, but this took only half the time to evaluate over the previous iteration.