input: Write a function to optimize an equation by combining like terms. The function should take a string representing the equation with terms separated by '+' and simplify it to have a count of each variable followed by the variable. If the given equation is empty then return an empty string.
  assert optimize_equation('x + x + y + y + y') == 'x^2 + y^3'
  assert optimize_equation('a + b + a') == 'a^2 + b'
  assert optimize_equation('c + c + c + d') == 'c^3 + d'
  assert optimize_equation('e + f + g + e + e + f') == 'e^3 + f^2 + g'
  assert optimize_equation('') == ''
output: def optimize_equation(equation):
      if not equation:
          return ''
      terms = equation.split(' + ')
      count = {}
      for term in terms:
          if term in count:
              count[term] += 1
          else:
              count[term] = 1
      result = []
      for term, cnt in count.items():
          if cnt > 1:
              result.append(f"{term}^{cnt}")
          else:
              result.append(term)
      return ' + '.join(result)