input: Write a function to optimize an equation by combining like terms and displaying each variable raised to its respective count. The input is a string representing the equation with sum of terms, and the output is a string representing the optimized equation. If the input is an empty string, return an empty string.
  assert optimize_equation('x + x + y + y + y')=='x^2 + y^3'
  assert optimize_equation('x + y + y')=='x^1 + y^2'
  assert optimize_equation('z + z + z + z + z')=='z^5'
  assert optimize_equation('')==''
  assert optimize_equation('a + a + a + b + b + c')=='a^3 + b^2 + c^1'
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 f"{term}^1" for term, count in term_count.items()]
      return ' + '.join(optimized_terms)