input: def optimize_equation(equation: str) -> str:
      """Optimize an equation by combining like terms.
      Example:
      for optimize_equation('x + x + y + y + y') == 'x^2 + y^3'
      """
output:     
      terms = {}
      for term in equation.split(' + '):
          if '^' in term:
              base, exp = term.split('^')
              exp = int(exp)
          else:
              base = term
              exp = 1
          if base in terms:
              terms[base] += exp
          else:
              terms[base] = exp
  
      optimized_terms = [f"{base}^{exp}" if exp > 1 else base for base, exp in terms.items()]
      return ' + '.join(optimized_terms)
  