Using Generating Functions To Count Things

alternative-proofcombinatoricselementary-number-theorygenerating-functions

At the theater, the movie X is currently showing. However, there are only $7$ tickets left in row $F$, $8$ tickets left in row $G$, and $9$ tickets left in row $H$.
A group of students enters the theater and wants to buy $6$ tickets with the requirement that there must be tickets in each of the three rows $F$, $G$, and $H$.
How many ways can the ticket seller sell tickets to the group of students?

I have done Direct Counting.
The answer to the counting problem is
$$C_{24}^6-[C_{15}^6+C_{17}^6+C_{16}^6-\left(C_7^6+C_8^6+C_9^6\right)]=109326.$$

I think the problem can use generating functions.
I am looking for such a way.

Best Answer

This is a math problem from my school, the solution is purely combinatorial. Here is the solution using generating functions. The problem of taking $n$ coins from $24$ people, with each person taking at most $1$ coin, can be represented by the generating function: $$[(1+x)^7-1] \cdot[(1+x)^8-1]\cdot [(1+x)^9-1]$$ $$=(1+x)^{24}-[(1+x)^{17}+(1+x)^{16}+(1+x)^{15}]+(1+x)^9+(1+x)^8+(1+x)^7-1.$$ The coefficient containing $x^n$ will be $$\binom{24}{n}-\left[\binom{17}{n}+\binom{16}{n}+\binom{15}{n}\right]+\binom{9}{n}+\binom{8}{n}+\binom{7}{n}.$$