input: Write a function to optimize an equation by combining identical terms. The function should take a string representing the equation as input and return a string with combined terms in the form of variable^count separated by ' + '. If the input string is empty, return an empty string.
  
  def optimize_equation(equation):
      if not equation:
          return ""
      variables = []
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          variables.append((var, int(count)))
  
      new_equation = ""
      for var, count in variables:
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]
  
  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('')==''
  assert optimize_equation('z')=='z^1'
  assert optimize_equation('h + h + h + h')=='h^4'
output: def optimize_equation(equation):
      if not equation:
          return ""
      term_dict = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in term_dict:
              term_dict[var] += 1
          else:
              term_dict[var] = 1
  
      new_equation = ""
      for var, count in term_dict.items():
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]