Combinatorics (Stars & Bars)
Competition Math · AMC 10/12 LevelPreview
1. Introduction
A huge family of AMC 10/12 counting problems boils down to the same question: in how many ways can we split a total into parts? How many ways to distribute identical candies among kids; how many nonnegative solutions to ; how many monomials of degree in three variables. The single technique that answers all of these is stars and bars.
The idea is beautifully visual. Represent the total as a row of identical stars, and use bars to chop the row into groups. Because the stars are indistinguishable, the only thing that matters is where the bars go — and counting bar placements is just a binomial coefficient. Once you internalize this picture, an entire category of problems collapses to "choose where the dividers go."
Stars and bars rarely travels alone at the contest level. The moment variables get upper bounds (a child can have at most candies), naive stars and bars overcounts, and we patch it with inclusion–exclusion. This article builds the method from the ground up — the basic count, the positive-solution shift, lower and upper bounds, the inclusion–exclusion machinery, and disguised appearances — with worked contest examples throughout.
2. Core Concepts
Concept 1 — The Stars and Bars Picture
Suppose we want nonnegative integer solutions to . Lay down identical stars () in a row. To divide them into groups, insert bars (). For example, with and , Every arrangement of stars and bars gives exactly one solution, and vice versa.
Concept 2 — Nonnegative Solutions (The Fundamental Count)
Stars and Bars Theorem (nonnegative). The number of solutions to with each is We are arranging symbols and choosing which of them are bars.
Concept 3 — Positive Solutions (Nonempty Boxes)
If each , give every variable one star up front by substituting . Then , so the count is Equivalently: place one item in each box first, then distribute the remainder freely.
Concept 4 — Lower Bounds by Shifting
A lower bound is handled by the same shift: set and reduce the total by . The count becomes when ; otherwise there are no solutions.
Concept 5 — Upper Bounds Require Inclusion–Exclusion
An upper bound cannot be removed by a simple shift. Instead, let be the set of solutions where . Subtract , add back , and so on. This is inclusion–exclusion.
Concept 6 — The Inclusion–Exclusion Principle
Inclusion–Exclusion Principle. For finite sets , For bounded stars-and-bars, we count all solutions, subtract violations, add back double violations, etc.
Concept 7 — The Slack Variable Trick ("At Most")
The number of nonnegative solutions to equals the number of solutions to with , which is The slack variable absorbs whatever is "left over."
Concept 8 — Violation Counting for One Upper Bound
If and we want solutions where , substitute and reduce the total by . The violation count is when ; otherwise .
Concept 9 — When Stars and Bars Applies
Stars and bars requires identical objects in distinct boxes. Distinct objects need -style counts or the multiplication principle. Identical objects in identical boxes (partitions) is a harder topic not covered here.
Concept 10 — Multinomial Coefficients
The number of ways to arrange objects where type appears times (with ) is the multinomial coefficient This is stars and bars in disguise: choosing positions for each type of star.
Concept 11 — Monomials of Fixed Degree
The number of monomials with and each is exactly — distribute degree units among variables.
Concept 12 — Dice Sums as Bounded Distributions
Rolling dice that sum to is equivalent to positive solutions to with . Shift to nonnegative with , then apply stars and bars plus inclusion–exclusion.
Continue reading with Premium
Upgrade to read the full article and unlock all Premium features.
Free
- Unlimited practice — all difficulties
- 3 hints / day
- Community solutions
- 2 timed mocks / month
Premium
- ✓Full article + all 57+ theory guides
- ✓Unlimited hints on practice problems
- ✓Unlimited timed mock exams & PDF worksheets