input: Write a function to optimize an equation by combining like terms. The function will take a string representing the equation and return a string with the terms combined. If the input is empty, return an empty string.
  assert optimize_equation("x + x + y + y + y")=="x^2 + y^3"
  assert optimize_equation("a + a + a + b + b")=="a^3 + b^2"
  assert optimize_equation("z + z + z + z")=="z^4"
  assert optimize_equation("c + d + e + f")=="c + d + e + f"
  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
      result = []
      for term, count in term_count.items():
          if count > 1:
              result.append(f"{term}^{count}")
          else:
              result.append(term)
      return " + ".join(result)