Solution
Lucky Tram Tickets
Show the problem again
Tram tickets carry six-digit numbers from 000000 to 999999, leading zeros included, so there are one million tickets. A ticket is lucky if the sum of its first three digits equals the sum of its last three. How many tickets are lucky? Give an integer.
Worked solution
The answer is 55252. Let $N_s$ count three-digit strings with digit sum $s$; the answer is $\sum_s N_s^2$. A neater route: replace each of the last three digits $d$ by $9-d$. A ticket is lucky exactly when the six digits of the new string sum to 27, so we need the number of digit strings of length 6 with sum 27. That is the coefficient of $x^{27}$ in $\left(\frac{1-x^{10}}{1-x}\right)^6$, which by inclusion-exclusion equals $\binom{32}{5} - 6\binom{22}{5} + 15\binom{12}{5} = 201376 - 158004 + 11880 = 55252$.
Source: The Soviet "lucky ticket" problem, a classic in wide circulation; no traceable original source. Statement written for AxiomIQ.