input: Write a function to optimize an equation by reducing the repeated addition of variables. The function should return the optimized equation in the form of a string with exponents indicating the number of occurrences of each variable.
  assert optimize_equation('x + x + y + y + y')=='x^2 + y^3'
  assert optimize_equation('a + a + a + b + b + c')=='a^3 + b^2 + c^1'
  assert optimize_equation('z + z + z + z + z')=='z^5'
  assert optimize_equation('p + q + r + s')=='p^1 + q^1 + r^1 + s^1'
  assert optimize_equation('')==''
output: def optimize_equation(equation):
      if not equation:
          return ''
      terms = equation.split(' + ')
      count = {}
      for term in terms:
          if term in count:
              count[term] += 1
          else:
              count[term] = 1
      optimized = [f"{var}^{count[var]}" if count[var] > 1 else var for var in count]
      return ' + '.join(optimized)