##DESCRIPTION
## Compound Inequalities
##
##ENDDESCRIPTION
# Original Problem Author: Modified by Shafiu Jibrin
# from setSets/ur_st_1_2.pg
# Location: Northern Arizona University
## DBsubject(Set theory)
## DBchapter(Basic properties and operations)
## DBsection(Union and intersection)
## Institution(The College of Idaho)
## Author(RA Cruz)
## Level(2)
## TitleText1('Essentials of Intermediate Algebra')
## AuthorText1('Blitzer')
## EditionText1('1')
## Section1('4.1')
## Problem1('')
## KEYWORDS('inequalities')
## Date: 2007/10
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"MathObjects.pl",
# "PGgraphmacros.pl",
# "PGnauGraphics.pl",
# "contextInequalitiesAllowStrings.pl",
"answerHints.pl",
# "CofIdaho_macros.pl"
);
TEXT(beginproblem());
######################################
# Setup
@slice = NchooseK(12,9);
@A = ($slice[1], $slice[2], $slice[3], $slice[4]);
@B = ($slice[5], $slice[6], $slice[8]);
$AiB = "N";
@AuB = ($slice[1], $slice[2], $slice[3], $slice[4], $slice[5], $slice[6],$slice[8]);
for ($k=3; $k>0; $k-=1) {
for ($i=0; $i<$k; $i+=1){
if($A[$i]>$A[$k]) {
$b = $A[$i];
$A[$i] = $A[$k];
$A[$k] = $b;
}
}
}
for ($k=2; $k>0; $k-=1) {
for ($i=0; $i<$k; $i+=1){
if($B[$i]>$B[$k]) {
$b = $B[$i];
$B[$i] = $B[$k];
$B[$k] = $b;
}
}
}
#for ($k=2; $k>0; $k-=1) {
# for ($i=0; $i<$k; $i+=1){
# if($AiB[$i]>$AiB[$k]) {
# $b = $AiB[$i];
# $AiB[$i] = $AiB[$k];
# $AiB[$k] = $b;
# }
# }
#}
for ($k=6; $k>0; $k-=1) {
for ($i=0; $i<$k; $i+=1){
if($AuB[$i]>$AuB[$k]) {
$b = $AuB[$i];
$AuB[$i] = $AuB[$k];
$AuB[$k] = $b;
}
}
}
$LEFT_BRACE = '\{';
$RIGHT_BRACE = '\}';
Context("Interval");
$ans_a = Set();
######################################
# Main text
Context()->texStrings;
BEGIN_TEXT
Let \( A= ${LEFT_BRACE} $A[0], $A[1], $A[2], $A[3] ${RIGHT_BRACE}\) , $SPACE
\( B= ${LEFT_BRACE} $B[0], $B[1], $B[2] ${RIGHT_BRACE}\).
$BR
Find the following sets in list form. Separate elements with commas. If there are no elements in the set, enter "NONE".
$PAR
a) \( A \cap B = \) \{$ans_a->ans_rule(25) \}
$PAR
b) \( A \cup B = \) \{ans_rule(25)\}
END_TEXT
Context()->normalStrings;
######################################
# Answer
ANS($ans_a->cmp);
Context()->parens->replace('{' => {close => '}', type => 'Set'});
# $ans_a = String("NONE");
#ANS($ans_a->cmp->withPostFilter(AnswerHints(
# sub {
# my ($correct,$student,$ans) = @_;
# if ($student=~ /\w/) {return $student !~ /[}{]/;}
# } => ["Enter your answer with set notation: { ... }",
# checkCorrect => 1,
# score => 0]
#)));
$ans_b = Set("{$AuB[0],$AuB[1],$AuB[2],$AuB[3],$AuB[4],$AuB[5],$AuB[6]}");
#Answer hints not working
ANS($ans_b->cmp->withPostFilter(AnswerHints(
sub {
my ($correct,$student,$ans) = @_;
return $student !~ /[}{]/;
} => ["Enter your answer with set notation: { ... }",
checkCorrect => 1,
score => 0]
)));
$showPartialCorrectAnswers = 1;
######################################
COMMENT('MathObject version');
ENDDOCUMENT();