# DESCRIPTION
# Use the inclusion/exclusion principle to determine
# the number of elements in a set
# WeBWorK problem written by Michael E. O'Sullivan
# and Thomas Schmidt
# ENDDESCRIPTION

## DBsubject(Combinatorics)
## DBchapter(Counting)
## DBsection(Inclusion/exclusion)
## Institution(SDSU)
## Author(Thomas Schmidt','Michael E. O'Sullivan)
## MLT(word3)
## MLTleader(1)
## Level(3)
## Static(1)
## MO(1)


############################
# Initialization

DOCUMENT();

loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "PGcourse.pl"
);

TEXT(beginproblem());

############################
# Setup

$showPartialCorrectAnswers = 0;

$A = "Italian";
$B = "Mexican";
$C = "American";

$nA = 120;
$nB = 210;
$nC = 220;
$nAintB = 60;
$nAintC = 75;
$nBintC = 100;
$nAuniBuniC = 330;

$answer = Compute(-$nA - $nB - $nC + $nAintB + $nAintC + $nBintC + $nAuniBuniC);

############################
# Main Text

Context()->texStrings;
BEGIN_TEXT
A random sample of $nAuniBuniC people showed that $nA people like $A food, $nB people like $B food, and $nC people like $C food.  If $nAintB like both $A and $B, $nAintC like both $A and $C, and $nBintC like both $B and $C, how many people like all three?
\{ans_rule(30)\}
$BR
$BR
END_TEXT
Context()->normalStrings;

############################
# Answer Evaluation

ANS($answer->cmp());

############################
# Solution

Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR Solution: $PAR
The general formula for the inclusion/exclusion principle is $BR
\(N(A\cup B\cup C) = N(A) + N(B) + N(C) - N(A\cap B) - N(A\cap C) - N(B\cap C) + N(A\cap B\cap C)\) $PAR
Since we have $PAR 
\(N($A) = $nA,\) $BR 
\(N($B) = $nB,\) $BR
\(N($C) = $nC,\) $BR
\(N($A\cap $B) = $nAintB,\) $BR
\(N($A\cap $C) = $nAintC,\) $BR
\(N($B\cap $C) = $nBintC,\) $BR
\(N($A\cup $B\cup $C) = $nAuniBuniC\), $PAR
and it is clear that $PAR 
\(N(A\cap B\cap C) = N(A\cup B\cup C) - N(A) - N(B) - N(C) + N(A\cap B) + N(A\cap C) + N(B\cap C)\), $PAR
then the answer is $BR 
\($nAuniBuniC - $nA - $nB - $nC + $nAintB + $nAintC + $nBintC = $answer\) $BR
END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();
