input: Write a function to optimize an equation by combining like terms and converting to a specific format.
  assert optimize_equation('x 1 + x 1 + y 1 + y 1 + y 1') == 'x^1 + x^1 + y^1 + y^1 + y^1'
  assert optimize_equation('a 2 + b 3 + a 2') == 'a^2 + b^3 + a^2'
  assert optimize_equation('x 5 + y 3 + z 2') == 'x^5 + y^3 + z^2'
output: def optimize_equation(equation):
      terms = equation.split(' + ')
      optimized_terms = []
      for term in terms:
          var, exp = term.split(' ')
          optimized_terms.append(f"{var}^{exp}")
      return ' + '.join(optimized_terms)