input: Write a function to optimize an equation by grouping the same variables and representing the count as an exponent. The function should take a string equation as input, where each term in the equation is separated by a plus sign, and return a new optimized string equation.
  
  def optimize_equation(equation):
      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') == 'a^3'
  assert optimize_equation('b + b + b + b') == 'b^4'
  assert optimize_equation('c + d + c') == 'c^2 + d^1'
  assert optimize_equation('') == ''
output: def optimize_equation(equation):
      if not 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]