input: 
  def optimize_equation(equation: str) -> str:
      """Optimize the given equation by combining like terms.
      >>> optimize_equation('x + x + y + y + y')
      '2x + 3y'
      >>> optimize_equation('a + b + b + c + c + c')
      '1a + 2b + 3c'
      """
      variables = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in variables:
              variables[var] += 1
          else:
              variables[var] = 1
  
      new_equation = ""
      for var, count in variables.items():
          new_equation += (str(count) + var + ' + ')
      return new_equation[:-3]
  
output:     variables = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in variables:
              variables[var] += 1
          else:
              variables[var] = 1
  
      new_equation = ""
      for var, count in variables.items():
          if count == 1:
              new_equation += (var + ' + ')
          else:
              new_equation += (str(count) + var + ' + ')
      return new_equation[:-3]