Discrete Math Tutor

Counting / Stars And Bars

Least You Need to Know: Stars and Bars

Stars and bars counts ways to distribute identical objects into distinct boxes by turning the problem into positions for separators.

The least you need to know

Key notation

one identical object
| separator between boxes
C(n,r) binomial coefficient

Tiny worked example

  • To count nonnegative solutions to `x+y+z=5`, draw 5 stars and 2 bars.\n- You choose the 2 bar positions among `5+2=7` total slots.\n- So the count is `C(7,2)=21`.

Common mistakes

How to recognize this kind of problem

Start practice