input: Write a function to optimize an equation by combining like terms. The function should take an equation as a string, where each term is separated by a '+' sign and consists of a variable followed by a space and its count. The function should return a string representing the optimized equation. If the input equation is empty, it should 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('')==''
  assert optimize_equation('z + z')=='z^2'
  assert optimize_equation('k + m + n')=='k^1 + m^1 + n^1'
output: def optimize_equation(equation):
      if not equation:
          return ''
      terms = equation.split(' + ')
      term_count = {}
      for term in terms:
          var, count = term.split()
          count = int(count)
          if var in term_count:
              term_count[var] += count
          else:
              term_count[var] = count
      optimized_terms = [f"{var}^{count}" if count > 1 else var for var, count in term_count.items()]
      return ' + '.join(optimized_terms)