# 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-1}C_{k-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-1}C_{k-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+2}C_{2 }= _{13}C_{2} = 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 _{999}C_{2} = 498501 solutions.