Solution
PINs Summing to Twenty
Show the problem again
A PIN is any string of four digits from 0000 to 9999. How many PINs have digit sum exactly 20? Give an integer.
Worked solution
The answer is 633. Count solutions of d₁ + d₂ + d₃ + d₄ = 20 with 0 ≤ dᵢ ≤ 9. Without the upper bound, stars and bars gives C(23, 3) = 1771. If a particular digit is at least 10, subtract 10 from it to get a free solution of a sum equal to 10: C(13, 3) = 286 for each of 4 choices of digit. Two digits can both be at least 10 only when they are exactly 10 and the rest are 0: C(3, 3) = 1 way for each of C(4, 2) = 6 pairs. Three digits cannot all exceed 9. Inclusion-exclusion: 1771 − 4 · 286 + 6 · 1 = 633.
Source: Classic counting exercise in wide circulation; no traceable original source. Statement written for AxiomIQ.