input: Write a function to optimize an equation by combining like terms. The function should accept a string representing the equation, where each term is separated by '+' and each term is in the form of "variable count". The function should return a string with the optimized equation in the form of "variable^count" for each term, and terms should be separated by ' + '. If the input string is empty, the function should return an empty string.
  def optimize_equation(equation):
      if 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 1 + b 2 + a 3 + b 4") == "a^4 + b^6"
  assert optimize_equation("m 0 + n 0") == "m^0 + n^0"
  assert optimize_equation("") == ""
output: def optimize_equation(equation):
      if equation == "":
          return ""
      variables = {}
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          count = int(count)
          if var in variables:
              variables[var] += count
          else:
              variables[var] = count
  
      new_equation = ""
      for var, count in variables.items():
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]