Combinatorics Made Simple

Stars and Bars: Counting Ways to Distribute Items

A visual counting trick for splitting identical items among players or slots, with worked examples, minimum-amount variations and a caution about equal likelihood.

On this page
  1. The problem it solves
  2. The picture
  3. The formula
  4. Variation: everyone gets at least one
  5. Variation: a different minimum
  6. Variation: counting dice outcomes where only the multiset matters
  7. An important warning about probability
  8. Choosing the right tool
  9. Quick check list

The problem it solves

Suppose you have 5 identical chips and want to share them among 3 players, and any player may receive zero. How many different splits are there? One split is (2, 2, 1), another is (5, 0, 0), another is (0, 3, 2). Because the chips are identical, only the amount each player gets matters, not which chip goes where.

Listing everything is doable here but not for larger numbers. Stars and bars turns it into a simple selection problem.

The picture

Draw the 5 chips as stars in a row: ★ ★ ★ ★ ★. To split them among 3 players, place 2 dividers, called bars, among the stars. The bars cut the row into 3 sections, one per player.

For example:

  • ★ ★ | ★ ★ | ★ means (2, 2, 1)
  • | ★ ★ ★ | ★ ★ means (0, 3, 2)
  • ★ ★ ★ ★ ★ | | means (5, 0, 0)

Every arrangement of 5 stars and 2 bars corresponds to exactly one split, and every split corresponds to exactly one arrangement. So the number of splits equals the number of different arrangements of the symbols.

The formula

There are 5 + 2 = 7 positions in total. You choose which 2 of them hold the bars; the stars fill the rest. That is a combination:

C(7, 2) = (7 × 6) ÷ (2 × 1) = 21

In general, distributing n identical items among k players, where zero is allowed, can be done in:

C(n + k − 1, k − 1)

ways. Here n = 5 and k = 3, giving C(7, 2) = 21. Choosing the positions of the bars is the same as choosing the positions of the stars, so C(7, 2) and C(7, 5) are equal.

Variation: everyone gets at least one

What if each player must get at least one chip? Give each player one chip first, which uses up 3 of the 5. That leaves 2 chips to distribute freely among 3 players:

C(2 + 3 − 1, 3 − 1) = C(4, 2) = 6

Equivalently, the formula for “at least one each” is C(n − 1, k − 1) = C(4, 2) = 6.

You can verify by listing. The splits of 5 into three positive parts are (3,1,1) in 3 orders and (2,2,1) in 3 orders, making 6 in total.

Variation: a different minimum

The same pre-giving trick works for any minimum. Say 10 skill points are spread across 4 attributes, any of which can be zero. That is C(10 + 4 − 1, 4 − 1) = C(13, 3) = (13 × 12 × 11) ÷ 6 = 1,716 ÷ 6 = 286 allocations.

If each attribute must receive at least 1 point, give 4 points out first, leaving 6 to distribute: C(6 + 3, 3) = C(9, 3) = 84. Check with the shortcut formula: C(10 − 1, 4 − 1) = C(9, 3) = 84 ✓.

If each attribute must receive at least 2 points, give out 8 first, leaving 2: C(2 + 3, 3) = C(5, 3) = 10.

Variation: counting dice outcomes where only the multiset matters

If you roll 3 six-sided dice and only care which values appeared, not which die showed what, this is like distributing 3 identical items (the dice) into 6 categories (the faces). Using n = 3 and k = 6:

C(3 + 6 − 1, 6 − 1) = C(8, 5) = 56

So there are 56 distinct multisets of results, for example {1, 1, 4} or {2, 5, 6}.

An important warning about probability

Do not read this as “each of the 56 outcomes has a 1/56 chance”. Three dice have 6 × 6 × 6 = 216 ordered outcomes, all equally likely. The multiset {1, 1, 4} can occur in 3 ways (the 4 could be on any of three dice), but {2, 5, 6} can occur in 6 ways. Counting multisets answers “how many different results exist?” not “how likely is each?”. To get probabilities, you still need to count the equally likely underlying outcomes, which matters for topics like dice pools and for any sum such as two-dice sums.

The same caution applies to splitting prizes or points when each assignment is not equally likely to occur. Stars and bars counts the possibilities. It does not weight them.

Choosing the right tool

  • Identical items, different recipients: stars and bars.
  • Different items, different recipients: multiply, since each item has k choices, giving k^n.
  • Choosing which items from a set: a combination.
  • Ordered arrangements: a permutation.

If you need to find how many ways identical raffle prizes or tokens could be shared, the counting follows this pattern, although the chance of any particular result depends on how the sharing is actually decided, as in raffle odds.

Quick check list

  1. Count the items n and the recipients k.
  2. If there are minimums, give them out first and reduce n.
  3. Use C(n + k − 1, k − 1) for the remaining items.
  4. Verify on a tiny version by listing.

Stars and bars is a counting device only. It says how many arrangements exist, and it carries no suggestion about improving your results in any game of chance.

The complete guide to combinatorics made simple

Combinatorics for Beginners: Counting Outcomes the Smart Way
Read the guide

Keep exploring

Guides from other topics

All topics →