Assemble a set of 14 from 3 sets of 7,8 and 10

60 Views Asked by At

Assuming we have a set of Democrats that has $8$ people, Republicans that have $10$ people and independent that have $7 $ people. How many combinations are there to pick $14 $ people?

So basically the question is to find the solution to $$ X_{i}+X_{d}+X_{r}=14 $$ $$ \begin{cases} X_{i}\le7\\ X_{d}\le8\\ X_{r}\le10 \end{cases} $$

I think it needs to be solved with inclusion-exclusion but I'm unsure how.

3

There are 3 best solutions below

0
On BEST ANSWER

All situations - unwanted cases such that $X_i \geq 8$ or $X_d \geq 9$ or $X_r \geq 11$

  • Unwanted cases : $|X_i \geq 8|+|X_d\geq9|+|X_r\geq11| -|X_i\geq8 \cap X_r\geq11|-|X_i\geq8 \cap X_d\geq9|-|X_d\geq9 \cap X_r\geq11|+|X_i\geq8 \cap X_r\geq11 \cap X_d\geq9|$ .Then , $$\binom{6+3-1}{2}+\binom{5+3-1}{2}+\binom{3+3-1}{2}-0-0-0+0 =59$$

  • All cases : $$\binom{14+3-1}{2}=120$$

So , $$120-59 =61$$

0
On

Using Python I managed to write some code to calculate it(not efficient but it seems to work):

def calcperm(N:int,r1:int,r2:int,r3:int):
"""

:param N: the number of solutions to X1+X2+X3=N
:param r1:  X1<=R1
:param r2:  X2<=R2
:param r3:  X3<=R3
:return:  number of solutions
"""
res=0
for i in range(r1+1):
    for j in range(r2+1):
        for k in range(r3+1):
            if(i+j+k==N):
                res+=1
return res
0
On

A cursory inspection shows that more than one group can't simultaneously violate the upper constraints, which makes computations quite easy.

Using the combinations with repetitions formula $\Large{\binom{n+k-1}{k-1}}$, we get

Valid combinations excluding violations of constraints

$=\Large{ \binom{16}2 - \binom{16-8}2 - \binom{16-9}2 - \binom{16-11}2 = 61}$