input: Write a function to optimize an equation by combining like terms. The function should take a string representing the equation and return a string representing the optimized equation.
  assert optimize_equation('x + x + y + y + y') == 'x^2 + y^3'
  assert optimize_equation('a + b + c') == 'a^1 + b^1 + c^1'
  assert optimize_equation('m + m + n + n + n + o') == 'm^2 + n^3 + o^1'
  assert optimize_equation('') == ''
output: def optimize_equation(equation):
      if not equation:
          return ''
      terms = equation.split(' + ')
      term_count = {}
      for term in terms:
          if term in term_count:
              term_count[term] += 1
          else:
              term_count[term] = 1
      optimized_terms = [f"{term}^{count}" if count > 1 else term for term, count in term_count.items()]
      return ' + '.join(optimized_terms)