On this page
In short The stars and bars method solves complex distribution problems by drawing identical items and dividers in a row. Popularised by the mathematician William Feller in 1950, it shows that sharing 10 identical sweets among 3 children creates 66 possible combinations.
When distributing identical items among distinct groups, the possibilities multiply rapidly. Listing every outcome by hand leads to mistakes. The stars and bars method turns this counting problem into a visual arrangement.
William Feller popularised this method in his 1950 textbook on probability theory (Wikipedia)). Representing items as stars and group boundaries as bars reduces the problem to choosing positions in a line.
What is the stars and bars method?
To distribute 10 identical sweets among 3 children, imagine the sweets lined up as ten stars (*). To split them into three portions, simply insert two vertical bars (|) into the line.
For example, * | * | means the first child gets three sweets, the second child gets five, and the third child gets two.
Because the sweets are identical, only the placement of the bars matters. Instead of thinking about children and sweets, you arrange 12 symbols (10 stars and 2 bars). You simply choose 2 positions for the bars out of the 12 spots.
If students struggle to picture these arrangements, the Fermi Simulation Lab provides interactive simulations for the ideas that are easier to see than to read. Seeing combinations mapped out visually bridges the gap before applying formulas blindly.
How do you distribute sweets with no restrictions?
To distribute n identical objects among k distinct bins (where a bin can be empty), you arrange n objects plus k − 1 dividers.
The formula for the total number of arrangements is (n + k − 1) choose (k − 1) (Wikipedia)).
For our 10 sweets and 3 children, n = 10 and k = 3. We need 2 bars. The arrangements are calculated as follows:
Find the total number of symbols, which is 10 + 2 = 12.
Choose 2 positions for the bars out of the 12 spots: 12 choose 2.
Calculate the combination: (12 × 11) / (2 × 1) = 66.
There are exactly 66 ways to share the sweets if children can receive zero sweets. This includes cases like ||********** where the third child receives all 10 while the others get nothing.
What if every child must get at least one sweet?
Often, a problem requires that no group is empty. If every child must receive at least one sweet, we adapt the approach.
First, give one sweet to each child. This uses 3 sweets, leaving 7 to be distributed freely among the 3 children with no restrictions.
Using stars and bars again, you have 7 stars and 2 bars. This means arranging 9 symbols. You choose 2 positions for the bars from 9 spots, which is 9 choose 2.
Calculating the combinations gives (9 × 8) / (2 × 1) = 36.
There are 36 ways to share the sweets without leaving anyone empty-handed. This logic is common in selection problems with combinations, where a mandatory phase prevents double-counting.
Alternatively, imagine placing the 10 sweets in a row, creating 9 gaps between them. To divide them into 3 non-empty groups, choose 2 of those 9 gaps for your bars. This leads directly to the same result of 36 ways.
Are the sweets identical or distinct?
A common trap is misidentifying the items. The stars and bars formula only works when the items are identical (like unbranded sweets) and the bins are distinct (like differently named children).
If the sweets were distinct (a chocolate bar, a lollipop, and a gummy bear), you would need permutations and powers, as the identity matters. This difference is related to combinations with and without replacement. Always verify whether the objects are distinguishable before drawing stars.
How does this help in exam prep?
Exam setters frequently disguise stars and bars problems. You might be asked to find the non-negative integer solutions to x + y + z = 10. This is mathematically identical to distributing 10 sweets among 3 distinct variables. Each variable represents a child, and its integer value is the number of sweets.
You can also use this logic to navigate sums of binomial coefficients. Whenever a problem asks you to distribute identical items into distinct groups, draw a quick row of stars and bars on paper. It serves as a reliable anchor, ensuring you pick the right numbers for your formula instead of guessing.



