Counting: March 9, 2017
Counting: March 9, 2017
Counting: March 9, 2017
March 9, 2017
1 Counting Principle
2 Permutations
Example 2.1. How many possible seating plans can be made for four people
to be seated at a round table?
Solution. Let A = {a, b, c, d} be the set of four persons. Let X be the set of
all permutations of A, and Y the set of all round permutations of A.
We define a map f : X Y as follows: for each permutation x1x2x3x4,
f (x1x2x3x4) is the round permutation by joining the front side of x1 to the end
side of x4, and x1x2x3x4x1 forms a clockwise direction of f (x1x2x3x4).
Clearly, f is onto. This is because for each round permutation, we may
separate any two neighbors and stretch them into a linear permutation. There
are exactly 4 places to separate a round permutation into a linear permutation.
For instance, the four cyclic permutations
abcd, bcda, cdab, dabc
are sent to the same round permutation abcda in clockwise direction. We
then have
|X| = 4|Y |.
Thus
|X| 4!
|Y | = = = 3! = 6.
4 4
Example 3.3. How many ways can six distinct objects be placed into three
distinct boxes so that the 1st, 2nd, and 3rd boxes contain 2, 3, and 1 objects
respectively?
Solution. Let A = {a, b, c, d, e, f } be the set of six objects. Let X be the
set of permutations of A, and Y the set of placements of elements of A into
three boxes so that the 1st, 2nd, and 3rd boxes receives 2, 3, and 1 elements,
respectively. There is a map f : X Y , defined by
f (x1x2x3x4x5x6) = {x1, x2}{x3, x4, x5}{x6},
where x1x2x3x4x5x6 is a permutation of A.
Clearly, f is onto. For each P Y , there are 2!3!1! permutations of A sent
to P . For instance, for P = {a, c}{b, d, f }{e},
acbdf e
acbf de
acdbf e
acdf be
acf bde
acf dbe f
2!3!1! 7 {a, c}{b, d, f }{e}
cabdf e
cabf de
cadbf e
cadf be
caf bde
caf dbe
Thus |X| = 2!3!1!|Y |. Therefore
|X| 6! 6
|Y | = = = = 60.
2!3!1! 2!3!1! 2, 3, 1
Theorem 3.3. The number of ways to place n distinct objects into k
distinct boxes, so that the 1st, 2nd, . . ., kth boxes contain n1, n2, . . . , nk
objects respectively, equals
n n!
= .
n1 , n2 , . . . , nk n1!n2! nk !
Remark. When considering
placement of n objects into two boxes of type
(r, n r), we write nr instead of
n n!
= .
r, n r r!(n r)!
Theorem 3.4. (Multinomial Theorem and Expansion)
(x1 + + xk )n =
X n n
xn1 1 xk k .
n1 ++nk =n
n1 , . . . , nk
n1 0,n2 0,...,nk 0
Proof.
(x1 + + xk )n
= (x1 + + xk ) (x1 + + xk )
| {z }
n
X
= u1 un (ui = x1, . . . , xk , 1 i n)
X # of sequences of x1, . . . , xk of
=
length n with n1 x1s, . . ., nk xk s
X n
n
= xn1 1 xk k .
n ++n =n
n1 , . . . , nk
1 k
n1 0,...,nk 0
Example 4.3. There are five types of color T-shirts on sale, black, blue, green,
orange, and white. John is going to buy ten T-shirts; he has to buy at least two
blues and two oranges, and at least one for all other colors. Find the number
of ways that John can select ten T-shirts.
Solution. We use 1, 2, 3, 4, 5 to denote black, blue, green, orange and white
respectively. Let xi be the number of T-shirts that John would select for the
ith color T-shirt. Then the problem is to find the number of integer solutions
for the equation
x1 + x2 + x3 + x4 + x5 = 10, (1)
where x1 1, x2 2, x3 1, x4 2, x5 1.
Let x1 = y1 + 1, x2 = y2 + 2, x3 = y3 + 1, x4 = y4 + 2, x5 = y5 + 1. Then
(1) becomes
y1 + y2 + y3 + y4 + y5 = 10 7 = 3
with yi 0, 1 i 5. Thus
5 5+31 7
answer = = = = 35.
3 3 3
Example 4.4. (a) In how many ways can a student order eight dumplings
from three different kinds? (Assume that there are enough supply of dumplings
of each kind.)
(b) In how many ways can a student eat five dumplings selected from the
three kinds for free under the condition that dumplings of the same kind should
be eaten consecutively one by one?
(c) The same question as (b) having 5 changed to n and 3 changed to m.
3 10
Solution. (a) 8 = 8 = 45.
(b) There are k3 ways to select k types of dumplings, 1 k 3.
For each selected k types of dumplings, to select 5 dumplings so that each
kind is selected, it can be done as follows: Select one from each kind first. Then
D 5 E k dumplings from the k types with repetition allowed. Thus there
select
k
are 5k such selections.
For each selected k types of dumplings and a selection of 5 dumplings from
the k types so that each kind is selected, there are exactly k! ways to eat the
dumplings. Thus
3
X 3 k
answer = k! = 63.
k 5k
k=1
Pm m
k
(c) answer = k=1 k! k nk .
5 Combinatorial Proof
Example 5.2.
2 2 2
2n n n n
= + + +
n 0 1 n
Proof. Consider n-combinations of 2n distinct balls, of which n balls are white
and the other n balls are black. Each n-combination can be obtained by taking
k balls from the n white balls and (n k) balls from the n black balls, where
0 k n. We then have
n
2n X n n
=
n k nk
k=0
n
X n n
=
k k
k=0
2 2 2
n n n
= + + + .
0 1 n
In general,
m+n X m n
= .
k i+j=k
i j
i,j0
6 Relation to Probability
Example 6.2. Find the probability that no two persons have the same birth-
day in a party of 40 people.
40
Solution. The number
of possible outcomes is 365 . The number of favorite
outcomes is 365
40
40!. Then
365
40!
probability = 40 40 0.109.
365
Example 6.3. What is the probability of rolling a pair of dice so that the sum
of numbers on the top facets equals 8?
First Method: Since there is no order between the two dice, there are 21 possible
outcomes
{i, j}, 1 i j 6
and three favorite outcomes {2, 6}, {3, 5}, {4, 4}. So the the probability is
3 1
21
= 7
0.14286.
Second Method: One may color the two dice as black and white so that the
two dice are ordered. There are 36(= 6 6) possible outcomes and five favorite
outcomes
(2, 6), (3, 5), (4, 4), (5, 3), (6, 2).
5
The probability equals 36 0.13889.
Which method is correct and why?
Example 6.4. Find the probability of rolling four dice simultaneously so that
the sum of points equals 9.
Solution. The number of possible outcomes is 64. The number of favorite
outcomes is the number of positive integer solutions of the equation
x1 + x2 + x3 + x4 = 9,
which is equal to the number of nonnegative integer solutions of the equation
y1 + y2 + y3 + y4 = 5.
Thus
4
5 7 1
probability = = .
64 162 23
7 Inclusion-Exclusion Principle
The identity (7) follows from the (8) by applying the operator w to both sides.
For each x U , we count the contribution of x on both sides of (8). We
divide the situations into three cases.
Case I: x satisfies fewer than m conditions.
In this case the contributions of x on both sides are 0.
Case II: x satisfies exactly m conditions, say, ci1 , , cim .
The contribution of x on the left side is 1. The contribution of x on the right
side is also 1 because x is counted once in Nm and 0 times in all Nk for k > m.
Case III: x satisfies exactly r conditions, say, ci1 , , cir , and r > m.
The contribution of x to the left side is 0. On the right side, the contributions
of x to Nm , Nm+1, . . ., Nr are
r r r
, , ..., , 0, . . . , 0
m m+1 r
respectively; and the contributions of x to Nk with k > r are all 0. Thus the
contribution of x to the right side is
m r m+1 r r r
+ + (1)rm .
0 m 1 m+1 rm r
Now it is easy to see that
rm
X m+j r
(1)j
j=0
j m+j
rm
X (m + j)! r!
= (1)j
j=0
j!m! (m + j)!(r m j)!
rm
X r! (r m)!
= (1)j
j=0
m!(r m)! i!(r m j)!
rm
X r r m
= (1)j
i=0
m j
rm
r X r m
= (1)j
m j=0 j
r rm
= (1) + 1 = 0.
m
Therefore the contributions of x on both sides are the same.
10 Pigeonhole Principle
Example 10.1. Among any five integers between 1 and 8 inclusive, there are
at least two of them adding up to 9.
Solution. We can divide the set {1, 2, . . . , 8} into four disjoint subsets where
each has two elements adding up to 9:
{1, 8}, {2, 7}, {3, 6}, {4, 5}.
When selecting five numbers from these four subsets, at least two of the five
selected numbers must come from a same subset of the four subsets. Thus their
addition is 9.
Example 10.2. Show that in any group of two or more persons there are at
least two having the same number of friends. (It is assumed that if a person x
is a friend of a person y then y is also a friend of x).
Solution. Consider a group of n persons, n 2. The number of friends of a
person x should be an integer k, where 0 k n 1. If there is one person
x whose number of friends is n 1, then everyone is a friend of x. Thus 0
and n 1 can not be simultaneously the numbers of friends of some people in
the group. The Pigeonhole Principle tells us that there are at least two people
having the same number of friends.
Example 10.3. Show that if a1, a2, . . . , ak are integers (not necessarily dis-
tinct), then some of them can be added up to a multiple of k.
Solution. Consider the following k + 1 integers (not necessarily distinct):
0, a1, a1 + a2, a1 + a2 + a3, . . . , a1 + a2 + + ak . (9)
By the Division Algorithm, the remainders of any integer dividing by k can
only be 0, 1, 2, . . . , k 1. By the Pigeonhole Principle, there are at least two
integers in (9), say,
a1 + + ai and a1 + + aj
having the same remainder dividing by k. (The integer a1 + + ai could be
0, the very first integer in (9).) Thus the difference
(a1 + + aj ) (a1 + + ai ) = ai+1 + ai+2 + + aj
is a multiple of k.
Example 10.4. Given 10 distinct integers a1, a2, . . . , a10 such that 0 ai <
100. Is there any subset of {a1, . . . , a10} such that the sum of numbers of the
subset with sign is zero?
Solution. Consider all possible partial sums of the selected numbers a1, a2, . . . , a10.
The values of these sums should be between 0 and 1000. Note that the number
of subsets of 10 objects is 210 = 1024. By the Pigeonhole Principle, there are
at least two subsets A, B {a1, a2, . . . , a10} such that
X X
ai = aj .
ai A aj B
Move the numbers on the right side to the left; the numbers of the intersection
A B will be canceled. Thus, the sum of integers of AB with positive sign
in A B and negative sign in B A equals 0.
Theorem 10.2. If n objects are placed in m boxes, then one of the boxes
must contain at least mn objects.
Problem Set 3
5. A bookshelf is to be used to exhibit ten math books. There are eight kinds
of books on Calculus, six kinds of books on Linear Algebra, and five kinds
of books on Discrete Mathematics. Books of the same subject should be
displayed together.
(a) In how many ways can ten distinct books be exhibited so that there
are five Calculus books, three Linear Algebra books, and two Discrete
Mathematics books?
(b) In how many ways can ten books (not necessarily distinct) be exhibited
so that there are five Calculus books, three Linear Algebra books, and
two Discrete Mathematics books?
Solution: (a) 85 63 52 5!3!2! 3!.
(b) 85 63 52 3!.
6. There are n men and n women to form a circle (line), n 2. Assume that
all n men are indistinguishable and all n women are indistinguishable.
(a) How many possible patterns of circles (lines) could be formed so that
men and women alternate?
(b) How many possible patterns of lines can be formed so that each man is
next to at least one woman?
(c) How many possible patterns of circles can be formed so that each man
is next to at least one woman and each woman is next to at least one
man?
Solution. Case I: All n men are indistinguishable and all n women are
indistinguishable.
(a) Circle case: 1. Line case: 2.
(b) It is clear that no three or more men can be seated together.
Line Case. Let k denote the number of pairs of men in a seating plan,
where 0 k n2 . We may think of two men seated next to each other
as one big man. Then there are k big men and n 2k men. So there are
total n k Men (men and big men). The number of seating plans for these
n k Men on a line is the number words of zeros
and ones with exactly k
ones and exactly n 2k zeros, which is nk k . Putting n k 1 women
between these n k Men, there are k + 1 remaining women. These k + 1
women can be arbitrarily distributed into n k + 1 locations among the
n k Men; there are h nk+1 n+1
k+1 i = ( k+1 ) ways to distribute the k + 1 women.
Thus the total number of required seating plans is
n/2
X n k n + 1
.
k k+1
k=0
Circle case: Let k be the number of pairs of man seating together. Then
0 k n2 , and there are also k pairs of women seating together. There
are n 2k single man and k double-man; there are also n 2k single
women and k double women, seating alternately. Then the number of
seating patterns with k double-men and k double-women is
1 X (n k)/d
(d),
nk k/d
d| gcd(k,n)
7. Four identical six-sided dice are tossed simultaneously and numbers showing
on the top faces are recorded as a multiset of four elements. How many
different multisets are possible?
Answer: h 64 i.
8. Find the number of non-decreasing coordinate paths from the origin (0, 0, 0)
to the lattice point (a, b, c).
a+b+c
Answer: a,b,c .
9. How many six-card hands can be dealt from a deck of 52 cards?
52 52
52
Answer: P6 = 6 6! (a hand is ordered); 6 (a hand is unordered).
10. How many different eight-card hands with five red cards and three black
cards can be dealt from a deck of 52 cards?
26
26 26
26
Answer: 5 3 8! (ordered); 5 3 (unordered).
11. Fortune draws are arranged to select six ping pang balls simultaneously
from a box in which 20 are orange and 30 are white. A draw is lucky if
it consists of three orange and three white balls. What is the chance of a
lucky draw?
( 203 )( 303 )
Answer: .
( 506 )
12. Determine the number of integer solutions for the equation
x1 + x2 + x3 + x4 38,
where
(a) xi 0, 1 i 4.
(b) x1 0, x2 2, x3 2, 3 x4 8.
Solution: (a) Note that there is a one-to-one correspondence between the
set of solutions for the inequality
x1 + x2 + x3 + x4 38
and the set of solutions for the equality
x1 + x2 + x3 + x4 + x5 = 38
with x5 0. Thus the number of solutions for the inequality is
5 5 + 38 1
= .
38 38
(b) Let x1 = y1, x2 = y2 + 2, x3 = y3 2, x4 = y4 + 3. Then the equation
becomes y1 + y2 + y3 + y4 35 with yi 0 for 1 i 4 and y4 5.
Solution: The number of solutions is the same as the number of solutions
of y1 + y2 + y3 + y4 + y5 = 35 with y4 5.
P
4 P5 38i
Answer: 5i=0 35i = i=0 35i
13. Determine the number of nonnegative integer solutions to the pair of equa-
tions
x1 + x2 + x3 = 8, x1 + x2 + x3 + x4 + x5 + x6 = 18.
Solution: We need to count
3
thenumber of tuples (x1, . . . , x6) satisfying
3
both equations. Answer: 8 10 = 10
8
12
10
.
14. Show that there must be at least 90 ways to choose six numbers from 1 to
15 so that all the choices have the same sum.
Solution: (a) The six selected numbers are not necessarily distinct. Note
that
1| + {z | + {z
+ 1} = 6, 15 + 15} = 90.
6 6
15 20
There are 85 integers in [6, 90]. However, 6 = 6 = 38760. Then are at
least 38760/85 = 456 ways to choose six integers (not necessarily distinct)
whose sums are the same. (b) The six selected numbers are distinct. Note
that 1+2+ +6 = 21 and 10+11+ +15 = 75. There are 55 integers in
[21, 75]. However, there are 15 6
= 5005 ways to select six integers. Thus
on average there are 5005/55 = 91 selections have the same sum.
15. Show that if five points are selected in a square whose sides
have length 2,
then there are at leat two points whose distance is at most 2.
Answer: Dividing the square of length 2 into 4 squares of length 1. Then
at least two points
must be in one small square, and the distance is less
than or equal to 2.
16. Prove that if any 14 numbers (not necessarily distinct) from 1 to 25 are
chosen, then one of them is a multiple of another.
Solution: Dividing integers in [1, 25] into 13 pigeonholes
{1, 2, 4, 8, 16}, {3, 6, 12, 24}, {5, 10, 20}, {7, 14}, {9, 18},
{11, 22}, {13}, {15}, {17}, {19}, {21}, {23}, {25}.
17. Twenty disks labelled 1 through 20 are placed face down on a table. Disks
are selected (by a player) one at a time and turned over until 10 disks have
been chosen. If the labels of two disks add up to 21, the player loses. Is it
possible to win this game?
Answer: Yes. Dividing 20 integers 1, 2, . . . , 20 into pigeonholes
{1, 20}, {2, 19}, {3, 18}, {4, 17}, {5, 16},
{6, 15}, {7, 14}, {8, 13}, {9, 12}, {10, 11}.
The chance the player can win the game is 210/ 20 10
.
18. Show that it is impossible to arrange the numbers 1, 2, . . . , 10 in a circle so
that every triple of consecutively placed numbers has a sum less than 15.
Solution: Let the 10 numbers be arranged as a1, a2, . . . , a10 in a circle so a1
is next to a10. Then a1 + a2 + a3 14, a4 + a5 + a6 14, a7 + a8 + a9 14,
and a10 10. Thus a1 + a2 + + a10 3 14 + 10 = 52. However,
a1 + a2 + + a10 = 1 + 2 + + 10 = 55, a contradiction.
19. In how many ways to arrange the letters E, I, M , O, T , U , Y so that
Y OU , M E and IT would not occur?
Solution: Let U be the set of all arrangements of
E, I, M, O, T, U, Y . Let A, B, and C be the sets of arrangements with
Y OU , M E, and IT respectively. Then
|A B C| = |U | |A| |B| |C| +
|A B| + |A C| + |B C|
|A B C|
= 7! 5! 6! 6! + 4! + 4! + 5! 3!.
20. Six passengers have a trip by taking a van of six seats. Passengers randomly
select their seats. When the van stops for a break, every passenger left the
van.
(a) What is the chance that the seat of every passenger after a break is the
same as their seat before the break?
(b) What is the chance that exactly five passengers have the same seats
before and after a break?
(c) What is the probability that at least one passenger has the same seat
before and after a break?
Solution: (a) 1/6!; (b) 0; (c) We find the probability p that no one got
his/her original seat. Let U be the set of all possible seating plans. Let Ai
be the set of all possible seating plans that the ith person got his original
seat, 1 i 6. Then
X X
p = |U | |Ai| + |Ai Aj |
i i<j
6 6 6
= 6! 5! + 4! 3! +
1 2 3
6 6 6
2! 1! + .
4 5 6
21. (Note required) Let M be a multiset of type (n1, n2, . . . , nk ) such that
ni 1 for 1 i k. If the numbers n1, n2, . . . , nk are all coprime with
n = n1 + n2 + + nk , then the number of round permutations of M is
n
n1 ,n2 ,...,nk
.
n
The formula is actually valid when gcd(n1, . . . , nk ) = 1, but we didnt
define the gcd yet for more than two integers. Find a counterexample if the
conditions are not satisfied.
22. (Not required) Find the number of nondecreasing lattice paths from the
origin (0, 0) to a non-negative lattice point (a, b), allowing only horizontal,
vertical, and diagonal unit moves; that is, allowing moves
(x, y) (x + 1, y),
(x, y) (x, y + 1),
(x, y) (x + 1, y + 1).
Hint: For any such path with k diagonal moves (0 k min{a, b}), the
number of horizontal moves should be a k and the number of vertical
moves should be b k. Thus
min{a,b}
X a+bk
answer: .
a k, b k, k
k=0