input: Write a function to optimize the given equation by combining like terms. The function should take a string representing the equation and return the optimized equation as a string.
  
  
  def optimize_equation(equation):
      variables = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in variables:
              variables[var] += 1
          else:
              variables[var] = 1
      
      optimized_equation = ""
      for var, count in variables.items():
          optimized_equation += var + '*' + str(count) + ' + '
  
      return optimized_equation[:-3]
  
  assert optimize_equation('x + x + y + y + y') == 'x*2 + y*3'
  assert optimize_equation('a + a + a + b') == 'a*3 + b*1'
  assert optimize_equation('p + q + q + p') == 'p*2 + q*2'
  assert optimize_equation('x + x + x + x + x') == 'x*5'
  assert optimize_equation('') == ''
  
output: def optimize_equation(equation):
      variables = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in variables:
              variables[var] += 1
          else:
              variables[var] = 1
      
      optimized_equation = ""
      for var, count in variables.items():
          optimized_equation += var + '*' + str(count) + ' + '
  
      return optimized_equation[:-3]