Counting unique students

132 Views Asked by At

A Kaggle.com question to fight spam is:

A total of 61 students are taking a probability course. 33 are majoring in mathematics, 29 in statistics, 18 in finance, 17 majoring in mathematics and statistics, 9 majoring in mathematics and finance, 10 majoring in statistics and finance, and 7 majoring in all three. What is the number of people not majoring in either mathematics, statistics, or finance?

My approach was to work backwards, by assuming that 7 is a unique number, then subtracting it from the 2-major group figures, then subtracting the sum of 7 + the 2-major group figures from the sum of 33 + 29 + 18 to figure out how many math, stats, and finance student to subtract from the original figure of 61.

I finally got it. My initial approach was correct, but apparently I must've punched in a wrong number somewhere along the line.

My logic was:

Let a = mathematics
Let b = statistics
Let c = finance 
  • 7 unique students major in a, b, and c
  • 3 additional unique students major in b and c (but not a; i.e. 7 of the 10 in the 2nd-to-last group described are the same 7 in a, b, and c)
  • 2 additional unique students major in a and c (but not b)
  • 10 additional unique students major in a and b (but not c)
  • There are 33 + 29 + 18 = 80 students described as majoring in a, b, or c, thus this count is of non-distinct records (80 > 61)
  • Of the 33 majoring in a, 33 - 7 - 10 - 2 = 14 are majoring exclusively in a
  • Of the 29 majoring in b, 29 - 7 - 10 - 3 = 9 are majoring exclusively in b
  • Of the 18 majoring in c, 18 - 7 - 2 - 3 = 6 are majoring exclusively in c
  • 14 + 9 + 6 = 29 are majoring exclusively in a, b, or c and 7 + 3 + 2 + 10 = 22 unique students are majoring in some combination thereof
  • Of the 61 students, 61 - 29 - 22 = 10 are not majoring in either mathematics, statistics, or finance

I actually had to do this twice to pass their check, probably because I answer the question above wrong before getting it right.


In the 2nd permutation it went like this:

  • 63 total students
  • 8 unique students major in math, stats, and finance
  • 13 additional unique students major in stats and finance
  • 10 additional unique students major in math and finance (but not stats)
  • 7 additional unique students major in math and stats (but not finance) therefore 28 unique multi-majors of math,stats, and/or finance

  • There are 31 + 32 + 36 = 99 students described as majoring in math, stats, or finance, thus this count is of non-distinct records (99 > 63)

  • Of the 31 majoring in math, 31 - 8 - 10 - 7 = 6 are majoring exclusively in math
  • Of the 32 majoring in stats, 32 - 8 - 13 - 7 = 4 are majoring exclusively in stats
  • Of the 36 majoring in finan, 36 - 8 - 13 - 10 = 5 are majoring exclusively in finance
  • 6 + 4 + 5 = 15 are majoring exclusively in math, stats, or finance and 8 + 13 + 10 + 7 = 38 unique students are majoring in some combination thereof
  • Of the 63 students, 63 - 15 - 38 = 10 are not majoring in either mathematics, statistics, or finance

Oy vey! What happened to the anti-spam questions where you click all the pictures containing pizza?

On my first pass I had 1 number off in 1 equation and got an answer of 12. Kaggle.com actually did accept this as the correct answer for some reason, but @N.F. Taussig has convinced me that the answer is 10 not 12 in his comments and solutions. Thanks!

1

There are 1 best solutions below

3
On BEST ANSWER

The Inclusion-Exclusion Principle states that

$$|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|$$

where $|S|$ denotes the number of elements in set $S$. Thus, the number of students in the class majoring in at least one of the three subjects is

\begin{align*} |A \cup B \cup C| & = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|\\ & = 33 + 29 + 18 - 17 - 9 - 10 + 7\\ & = 51 \end{align*} Since there are a total of $61$ students in the class, there are $10$ students taking the probability class who are not majoring in at least one of the subjects mathematics, statistics, and finance.