Counting Overview
ICS 6D
Sandy Irani
Balls into Bins
• n balls
• m bins
• Bins are distinguishable (labeled with numbers)
No restrictions
on the number of
balls per bin
Distinguishable
Balls
Indistinguishable
Balls
At most one ball
per bin
mn
ri balls in bin i
For i = 1,…,m
r1+r2+r3+…+rm = n
Distinguishable Balls into
Distinguishable Bins (no restrictions)
Ball1
Ball2
Ball3
Ball4
….
Ball (n-1) Ball n
• Each ball goes into exactly one bin.
• Each bin can get any number of balls.
Dist Balls/Dist Bins/No Restrictions
• Count the number of strings of length n over
an alphabet with m characters.
Char1 Char2 Char3 Char4
….
Char (n-1) Char n
Dist Balls/Dist Bins/No Restrictions
• How many ways to plan a schedule for n days.
Each day, there are exactly m choices of
activities.
Day1
Day2
Day3
Day4
….
Day (n-1) Day n
Dist Balls/Dist Bins/No Restrictions
• How many ways to distribute n different items
to m people?
Item1 Item2 Item3 Item4
….
Item(n-1) Item n
Dist Balls/Dist Bins/No Restrictions
• How many ways to assign m different people
to n jobs? (Each job needs one person. A
person can get any number of jobs).
Job1
Job2
Job3
Job4
….
Job(n-1)
Job n
Indistinguishable Balls into
Distinguishable Bins (No restrictions)
• Can have n m or m n
Bin 1
Bin 2
Bin 3
n m 1
m 1
Bin m-1
Bin m
Indist Balls/Dist Bins
(No restrictions)
• How many ways to pick n items from m
varieties?
– Items of the same variety are the same
– Large number of each variety
– Order of selection does not matter
• # of variety j chosen = # balls in bin j
• Total number chosen = total number of balls
Indist Balls/Dist Bins
(No restrictions)
• How many solutions to the equation:
x1 + x2 + x3 + ….+ xm = n
Each xj is a non-negative integer (xj 0)
• xj = # balls in bin j
Indist Balls/Dist Bins
(No restrictions)
• How many ways to distribute n identical items
to m people?
• # items to person j = # balls in bin j
Dist Balls to Dist Bins
At most one ball per bin
• Must have m n
2
3
Bin 1
Bin 2
1
Bin 3
Bin m-1
Bin m
• If balls are placed in order, the order of placement matters.
# choices
for
ball 1
x
# choices
for
ball 2
x
# choices
for
ball 3
x ….
x
# choices
for
ball n
Dist Balls to Dist Bins
At most one ball per bin
• How many strings of length n from a set of m
characters with no repetition?
# choices
for
char 1
x
# choices
for
char 2
x
# choices
for
char 3
x ….
x
# choices
for
char n
Dist Balls to Dist Bins
At most one ball per bin
• How many ways to distribute n different items
to m people with at most one per person?
# choices
for
item 1
x
# choices
for
item 2
x
# choices
for
item 3
x ….
x
# choices
for
item n
Dist Balls to Dist Bins
At most one ball per bin
• How many ways to select n people from a
group of m people in which each person
chosen is assigned a distinct task?
# choices
for
task 1
x
# choices
for
task 2
x
# choices
for
task 3
x ….
x
# choices
for
task n
Indist Balls to Dist Bins
At most one ball per bin
• Must have m n
Bin 1
Bin 2
Bin 3
Bin m-1
Bin m
• The order of ball placement does not matter.
• Which bins have a ball?
n of the m bins have a ball.
# of ways to place balls = # ways to pick a subset of n from
{1, 2, 3, …., m}
Indist Balls to Dist Bins
At most one ball per bin
• How many ways to pick a committee of n
people from a group of m people?
• How many binary strings of length m have
exactly n 1’s?
*
Dist Balls/Dist Bin
Fixed number per bin
• Restriction: exactly rj balls in bin j, for m j 1
• r1+r2+r3+…+rm = n
Pick r1 balls for bin 1.
Then pick r2 balls for bin 2.
….
Finally, pick rm balls for bin m.
Dist Balls/Dist Bin
Fixed number per bin
• How many ways to assign n people to offices?
There are m offices. Office j can hold rj people.
• r1+r2+r3+…+rm = n
Pick r1 people for office 1.
Then pick r2 people for office 2.
….
Finally, pick rm people for office m.
Dist Balls/Dist Bin
Fixed number per bin
• How many ways to plan a schedule for n days.
Each day, there are exactly m choices of activities.
• Activity j appears rj times in the schedule.
• r1+r2+r3+…+rm = n
Pick r1 days for activity 1.
Then pick r2 days for activity 2.
….
Finally, pick rm days for activity m.
Indist Balls/Dist Bin
Fixed number per bin
• Restriction: exactly rj balls in bin j, for m j 1
• r1+r2+r3+…+rm = n
Bin 1
Bin 2
Bin 3
Bin m-1
• There are no decisions to make.
• Number of ways to place the balls = 1
Bin m
Indist Balls/Dist Bin
Fixed number per bin
• How many ways to distribute n identical
chocolate bars to m kids so that each kid gets
exactly the same number of chocolate bars?
(n must be a multiple of m)
• Exactly 1 way to distribute the chocolate bars.
Permutation Questions
• How many ways to line up 9 people…
– No restrictions
– Person A to the immediate left of Person B
– Person A next to Person B
Permutation Questions
• How many ways to line up 9 people…
– Either Person A or Person B is in the leftmost
position.
– Neither Person A nor Person B is in the leftmost
position
Permutation Questions
*
• How many ways to line up 9 people…
– Person A is the leftmost or the rightmost position
– Person A is somewhere to the left of Person B (but
not necessarily the immediate left)
© Copyright 2026 Paperzz