16 programmers were asked if they knew Pascal, C++ and Java. How many of them knew C++ and Java simultaneously but did not know Pascal?

154 Views Asked by At

$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?

2

There are 2 best solutions below

0
On BEST ANSWER

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)$.

3
On

as you said:

$16 = |A| + |B| + |C| − |A∩B| − |A∩C| − |B∩C| + |A∩B∩C|$

$-|B∩C| = 16 - |A| - |B| - |C| + |A∩B| + |A∩C| - |A∩B∩C|$

$-|B∩C| = 16 - 12 - 15 - |C| + |C| + 8 - |A∩B∩C|$

$|B∩C| = 3 + |A∩B∩C|$

now we have from the question that from the 16 people who were asked, 15 of them knew c++ so at most 1 person doesn't know c++, the number of people who know java and pascal is 8, so either the person who doesn't know c++ knows both java and pascal or she doesn't. which means :

$ |A∩B∩C| = 8$ or $7$

so your answer can be 10 or 11 since there's no more clues in the question and they're both admissible.

edit:

my answer counted the number of people who know java and c++ (whether they know pascal or not) the answer for people who only know java and c++ is as said in the comments

$|B∩C| - |A∩B∩C| = 3 $