# Stars and Bars (Combinatorics)

The method of "Stars and Bars", ("Balls and Sticks", "Dots and Lines", etc.) is a simple and useful tactic for engaging seemingly convoluted combinations problems. This strategy is useful in a wide variety of math competitions, such as Mathcounts, AMC, AIME, ARML, and so forth, and is also applicable in some computer algorithms.

## Idea and Proof

Essentially, if there are n indistinguishable objects to be divided into k distinguishable groups, then there are n+k-1Ck-1 ways* of distributing the objects.

We can partition objects, or "Stars" by use of dividers or "Bars". Since 1 bar divides into 2 groups, 2 bars into 3 groups, and so forth, the number of bars will be k-1. By scrambling the n objects and the k-1 bars, various unique divisions can be formed. Hence, there are n+k-1Ck-1 orderings.

* If you are unfamiliar with this notation, http://laurashears.info/math122/unit5/notation/.

## Example 1

There are 11 customers and 3 cashiers. How many ways can the customers line up to the cashiers, if the order of each line does not matter.

This is a direct application of the Stars and Bars method. There are 11 customers (Stars), so n = 11. There are 3 cashiers, which require 3-1 or 2 divisions (Bars). Hence, there are 11+2C2 = 13C2 = 13*12/2 = 78 possible lineups.

## Example 2

How many ordered triples of positive integers satisfy a+b+c = 1000?

Although not apparent at first, we can consider the problem as a Stars and Bars problem by letting a,b,c be the groups, and the numbers being the objects. Since the problem considers positive integers, if we want to include 0, make the transformation A = a-1, B = b-1, C = c-1. Then, A+B+C = 997, where A,B,C are whole numbers.

The reason for this transformation is because when Stars and Bars is applied, there can be empty groups, or "0". Now, groupings such as

★★ | ★ | ★★  represents (2,1,2)

| ★ | ★★★★  represents (0,1,4)

★★★★★ | |  represents (5,0,0)

There are now 997 Stars, and 3-1 = 2 Bars, so there are 999C2 = 498501 solutions.

## Related Books

trueprober 3 years ago

Excellent work! This would encourage any one who wants to make an entry into the realm of mathematics. Keep it up

Titus 2 years ago

This was very helpful... thanks! One question though. From what I understand, shouldn't the answer to Example 2 be C(997, 2) instead of C(999,2)? Thanks!