text: ##DESCRIPTION
  ## Simplify Exponents
  ## 
  ##ENDDESCRIPTION
  ## DBsubject(Algebra)
  ## DBchapter(Properties of exponents, rational exponents and radicals)
  ## DBsection(Properties of exponents)
  ## Institution(The College of Idaho)
  ## Author(RA Cruz)
  ## MLT(Division_exponents_multivar)
  ## Level(2)
  ## MO(1)
  ## TitleText1('Essentials of Intermediate Algebra')
  ## AuthorText1('Blitzer')
  ## EditionText1('1')
  ## Section1('1.6')
  ## Problem1('')
  ## KEYWORDS('real numbers','algebraic expressions','exponents')
  ## Date: 2007/09
  
  DOCUMENT();        # This should be the first executable line in the problem.
  
  loadMacros(
    "PGstandard.pl",
    "MathObjects.pl",
    "contextLimitedPowers.pl",
    "answerHints.pl",
    "CofIdaho_macros.pl",
    "PGcourse.pl"
  );
  
  TEXT(beginproblem());
  
  ######################################
  #  Setup
  
  @alphabet = ("a","b","c","x","y","z");
  $choose = random(0,3,3);
  @var = ($alphabet[$choose], $alphabet[$choose+1], $alphabet[$choose+2]);
  Context()->variables->are($var[0]=>'Real',
                           $var[1]=>'Real', 
                           $var[2]=>'Real');
  
  $n1 = random(7,20,1);
  $m1 = $n1 - random(2,5,1);
  $n2 = random(7,20,1);
  $m2 = $n2 - random(2,5,1);
  $n3 = random(7,20,1);
  $m3 = $n3 - random(2,5,1);
  $num2 = random(2,7,1);
  $num1 = $num2 * random(5,11,1); #To keep whole numbers in the answer
  
  ######################################
  #  Main text
  
  BEGIN_TEXT
  Divide using the quotient rule:
  $PAR
  \( \displaystyle \frac{$num1 $var[0]^{$n1}$var[1]^{$n2}$var[2]^{$n3}}{$num2 $var[0]^{$m1} $var[1]^{$m2}$var[2]^{$m3}} \) =  \{ ans_rule(20) \}
  END_TEXT
  
  ######################################
  #  Answers
  # Format the answer so that it shows up correctly
  # in the "Correct Answer" box, i.e. put the variables
  # with negative exponents in the denominator.
  # NOTE: If more variables are used, just put 
  # the exponents in the @expos vector in order.
  
  Context()->operators->set(@LimitedPowers::OnlyPositiveIntegers);
  
  $numerator = $num1/$num2;       #Constants
  $denominator = 1;
  @expos = ($n1-$m1,$n2-$m2,$n3-$m3);
  
  $ans = SimplifyExponents($numerator,$denominator,~~@var,@expos);
  
  ANS($ans->cmp->withPostFilter(AnswerHints(
     sub {
         my ($correct,$student,$ah) = @_;
         ##Count the number of variables--(Better if checked for reduced constants too.)
         my $CorrectVariableNumber = $correct =~ tr/a-zA-Z//;  
         my $StudentVariableNumber = $student =~ tr/a-zA-Z//;
         return $ah->{score}==1 && $CorrectVariableNumber<$StudentVariableNumber;
         } => ["Simplify your answer.", 
               checkCorrect => 1, 
               score => 0]
  )));
  
  $showPartialCorrectAnswers = 1;
  
  ######################################
  
  
  ;
  ENDDOCUMENT();
  