input: def optimize_equation(equation: str) -> str:
      """
      Optimize the given equation by combining like terms and returning the simplified equation.
      The input equation is a string where each term is separated by a '+'. Each term is in the format 'var count'.
      The function should combine terms with the same variable and return a string in the format 'var^count'.
      
      >>> optimize_equation('x 2 + y 3 + x 1')
      'x^3 + y^3'
      >>> optimize_equation('a 1 + b 2 + a 1 + b 1')
      'a^2 + b^3'
      """
      variables = {}
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          if var in variables:
              variables[var] += int(count)
          else:
              variables[var] = int(count)
  
      new_equation = ""
      for var, count in variables.items():
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]
output:     variables = {}
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          if var in variables:
              variables[var] += int(count)
          else:
              variables[var] = int(count)
  
      new_equation = ""
      for var, count in variables.items():
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]