# Understanding inclusion exclusion principle (with example question).

Hi here is a question that i solved with generating functions , and i try to solve the same question with the inclusion exclusion principle.

Question: We have four type of balls - Red,Blue,Green,White We only have ten for each color. Find out how many ways you can select 24 balls. Order is not important.

My solution for the problem with generating functions his: \begin{align} f(x) &=(1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^{10})^4 \\ {{a}_{24}} &=? \\ f(x) &= ((1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^{10})^2)^2 \\ & ={{(1+2x+3{{x}^{2}}+4{{x}^{3}}+5{{x}^{4}}+6{{x}^{5}}+7{{x}^{6}}+8{{x}^{7}}+9{{x}^{8}}+10{{x}^{9}}+11{{x}^{10}}+10{{x}^{11}}+9{{x}^{12}}+8{{x}^{13}}+7{{x}^{14}}+6{{x}^{15}}+5{{x}^{16}}+4{{x}^{17}}+3{{x}^{18}}+2{{x}^{19}}+{{x}^{20}})}^{2}} \\ & =..... \\ {{a}_{24}}&=745 \\ \end{align}

Now i try to solve the problem with inclusion exclusion so: ${{x}_{1}}+{{x}_{2}}+{{x}_{3}}+{{x}_{4}}=24$ ${{x}_{i}}\le 10\text{ for }1\le i\le 4$. how should i solve it with this condition?

What is my $|U|=?$ (complement of a set) and why?

Without the limit of $10$ balls available for each colour, the number of possibilities is a straightforward stars&bars combination/classification problem, giving total combinations of $${27\choose 3}=2925$$
To find out how many of these break the constraint on Red balls, preallocate 11 balls to Red then run stars&bars on the remaining number to select. $${16\choose 3}=560$$ Subtracting this four times, one for each colour (since they all have the same constraint), will overcompensate for cases where two of the colours break the 10 limit. So assess how many of such cases there might be with another preallocation of 11 to two colours this time:$${5\choose 3}=10$$ There are ${4\choose 2}=6$ options for two simultaneous limits exceeded, and fortunately no way that 3 limits can be broken simulatneously. So our final inclusion-exclusion result is $${27\choose 3}-{4\choose 1}{16\choose 3} +{4\choose 2}{5\choose 3} =2925-4\times 560+6\times 10 = 745$$matching your generating function answer.