$16$ programmers were asked if they knew Pascal, C++ and Java. It turned out that:
- $12$ knew Pascal
- $15$ knew C++
- Java language knew as many programmers as Pascal and C++ knew simultaneously,
- $8$ knew pascal and Java.
How many programmers knew C++ and Java simultaneously but did not know Pascal?
My approach:
- A - Pascal
- B - C++
- C - Java
$16 = |A∪B∪C| = |A|+|B|+|C| -|A∩B| - |A∩C|-|B∩C|+ |A∩B∩C|$
We also that $8$ people know both Pascal and Java so $|A∩C|= 8$, and from third fact number of people who know Java is the number who know both Pascal and C++ so $|C| = |A∩B|$.
Back to first equation of $|A∪B∪C| = 16$ we get:
$16 = |A|+|B|+|C| -|A∩B| - |A∩C|-|B∩C| + |A∩B∩C|$
$16 - 12 - 15 - |C| + |C| + 8 = -|B∩C|+ |A∩B∩C|$ (as $|A∩B|=C$ and $|A∩C|= 8$)
$-3$ = -$|B∩C|+ |A∩B∩C|$ What i'm looking for is $|B∩C|$ but to do so I need to have $|A∩B∩C|$ any ideas?
Denote by $x_P$, $x_{PC}$, etc., the number of persons that know exactly P, resp., P and C, etc. I'm assuming that each person knows at least one of the given languages, and that the problem has at least one solution with all $x_\iota$ nonnegative. Then we have the following equations, whereby $(4)$ collects the persons that dont know C${}^{++}$: $$x_P+x_{PC}+x_{PJ}+x_{PCJ}=12\ ,\tag{1}$$ $$x_J+x_{CJ}+x_{PJ}+x_{PCJ}=x_{PC}+x_{PCJ}\ ,\tag{2}$$ $$x_{PJ}+x_{PCJ}=8\ ,\tag{3}$$ $$x_P+x_{PJ}+x_J=1\ .\tag{4}$$ We use $(3)$ to eliminate $x_{PCJ}$ from $(1)$; furthermore $x_{PCJ}$ can be cancelled in $(2)$: $$x_P+x_{PC}=4\ ,\tag{5}$$ $$x_J+x_{CJ}+x_{PJ}=x_{PC}\ .\tag{6}$$ Subtracting $(6)$ from $(4)$ we obtain $$x_P-x_{CJ}=1-x_{PC}\ ,$$ hence $$x_{CJ}=x_P+x_{PC}-1=3\ ,$$ using $(5)$.