**Unformatted text preview: **MATH 340 Discrete Mathematics Winter 2020 Assignment 1
Due date: Thursday, February 6, 2020 at 4:05. Solutions You can work out the problems with your friends, but every student must submit their own
solutions, written in their own words: otherwise it may be considered as plagiarism. Late
submissions will be penalized by 10% o per day after the deadline. Paper submissions
(in class) are strongly encouraged.
Question 1 (20 marks) A website asks you to login in order to be able to write on its guestbook. But of course,
it won't let you choose just any string as a password: that would be too simple! Instead,
the requirements are the following:
1. The password must contain between 8 and 10 characters.
2. Each character must be of one of the following types: lowercase letters without
accents (az), uppercase letters without accents (AZ), digits (09) or special characters from the following list: !?#&@%*~$_
3. The password contains at least one character of at least three of the four types
mentioned above.
In how many ways can a password be chosen in order to meet all those requirements? That way of thinking about internet security is completely obsolete, but somehow
still common. XKCD has a comic strip about that... See
Note: Solution: Let's rst name and count each set of characters...
L = {Lowercase letters}
U = {Uppercase letters}
D = {Digits}
S = {Special characters} |L| = 26
|U | = 26
|D| = 10
|S| = 10 Let pk be the number of valid passwords, for k = 8, 9, 10. We will count each pk separately,
so that by the sum principle, the total number of valid passwords is p8 + p9 + p10 .
There are 2 × 26 + 2 × 10 = 72 admissible characters in total, so 72k possible strings of
length k, and from that, we want to subtract the number qk of strings that just use one or
two types of characters. So pk = 72k − qk by the complement principle.
Now, to count qk , we need to split in cases according to the two sets of characters that are
used. • |L ∪ U | = 52, so there's 52k strings made just with lowercase and uppercase letters.
• |D ∪ S| = 20, so that's 20k strings made just with digits and special characters.
• |L ∪ D| = |L ∪ S| = |U ∪ D| = |U ∪ S| = 36, so that's 36k strings made just with two of those types of characters, for each of the four possibilities. Note that the strings made with just one type of character were counted exactly 3 times
in the cases above, for each type of chracter. So we need to remove two times the (26k +
26k + 10k + 10k ) strings made of just one type of character from the total above in order
to count them just once.
Combining all of this together, we nd:
pk = 72k − qk = 72k − 52k − 20k − 4 · 36k + 4 · 26k + 4 · 10k . Substituting values for k, we nd p8 = 658270076405760, p9 = 48833762118635520 and
p10 = 3585280971297792000, for a total of 3634773003492833280 valid passwords.
Question 2 (20 marks) Let (a1 , . . . an ) be any nite sequence of n integers. Show that there exist two indices s
and t, with 1 ≤ s ≤ t ≤ n, such that
t
X ai ≡ 0 mod n i=s Hint: You should use the Pigeonhole principle....
Solution: First consider the partial sums where s = 1. That is, sums of the form
1 ≤ t ≤ n.
Assume that
t
X ai ≡ rt Pt i=1 ai , where mod n i=1 If rt = 0 for any 1 ≤ t ≤ n, then we are done. So rt ∈ {1, 2, . . . , n − 1} for each
1≤tP
≤ n. Thus,Pby the pigeon-hole principle, there exist t1 < t2 such that rt1 = rt2 = r.
1
2
Thus ti=1
ai = ti=1
ai ≡ r mod n. Thus
t2
X ai − i=1 But the LHS is just Pt2 i=t1 +1 ai ≡ 0 mod n i=1 ai . So setting s = t1 and t = t2 we have
t
X
i=s Question 3 (20 marks) t1
X ai ≡ 0 mod n (a) Give an algebraic proof of the following identity.
2n
n
=2
+ n2
2
2
(b) Give a combinatorial proof of the same identity. Solution:
(a) Write out the denition in terms of factorials and simplify. The left hand side gives
us
2n
2 = 1
· 2n · (2n − 1) = n · (2n − 1) = 2n2 − n
2 The right hand sides gives us
n
1
2
+ n2 = 2 · · n · (n − 1) + n2 = n · (n − 1) + n2 = 2n2 − n
2
2 So the two are equal.
(b) The LHS is clearly the number of ways to choose two numbers from the set S = {1, 2, 3, . . . , 2n}. Let's see that the RHS also counts this. Divide
the set S into A = {1, 2, 3, . . . , n} and B = {n + 1, n + 2, . . . , 2n}. There are
n
ways to choose two numbers from A, n2 ways to choose two numbers from B ,
2
and n2 ways to choose one number from A and one number from B . This covers all
ways to chose two numbers from S .
Question 4 (20 marks) Let p ≥ 3 be a prime number, and mark p points at equal distance on the circumference
of a circle like in the pictures below (where p = 7). We can trace polygons by choosing
a certain amount of those points as vertices, and connecting them with non-intersecting
straight lines. How many dierent polygons can we form:
(a) if we consider that a dierent choice of vertices leads to a dierent polygon?
(b) if we count all dierent rotations of the same polygon as a single polygon? = (c) if we count all isometric polygons (all rotations and reections of the same polygon) as the same ? = = Solution:
(a) We just need to choose k ≥ 3 vertices out of p possibilities. There are 2p subsets
in total, from which we remove 1 + p + p2 subsets with 0, 1 or 2 elements. So the
answer is:
2
2p − (b) p +p+2
.
2 Let A be our answer in part (a), and let B be the answer we now seek. Note that
each polygon with between 3 and p−1 vertices has been exactly counted p times in A,
because the full polygon with p vertices is the only one that is a non trivial rotation
of itself (so this was counted only once). Therefore,
p(B − 1) = A − 1 . Substituting our answer from A and isolating B , we nd:
B=
(c) 2p p2 − p + 4
−
.
p
2p Let C be the answer we now seek. Note that not all polygons have been counted the
same amount of times in B . In fact:
• The full polygon with p vertices has been counted only once.
• Each symmetric polygon (a polygon that is identical to a reection of itself)
with between 3 and p − 1 vertices has been counted once as well.
• Each non symmetric polygon has been counted exactly twice, because we con- sidered those polygons and their reection as two dierent polygons. Let S be the number of symmetric polygons with between 3 and p − 1 vertices and
N be the number of non symmetric polygons. The remarks above translate into the
equations:
C =N +S+1
B = 2N + S + 1 . The following equation follows from the above two:
2C − B = S + 1 . Since we already know the value of B , then we just have to nd S to be able to
compute C from that equation. So let's count the symmetric polygons with between
3 and p − 1 vertices...
We x the axis of symmetry to be, say, horizontal, so that we do not count the
rotations. For each vertex, there are two options: that vertex may belong to the
polygon, or not. Note that since p is odd, then one of the vertices (say, Vertex 1) is
on the axis. For each other vertex, since the polygon is symmetric, then the choices
choices to
above the reection axis are reected below, so there are really just p−1
2
make, for the vertices above the axis. We split in two cases:
• Case 1: Vertex 1 belongs to the polygon. Then we need to choose at least one other vertex to form the polygon (we discard the empty set), but also avoid
choosing them all since that would result in the full polygon that we do not
want to count... So we count those two choices out and the resulting number
of polygons is:
2(p−1)/2 − 2 . • Case 2: Vertex 1 does not belong to the polygon. Then we need to choose at least two vertices above the axis to form the polygon. So we count out the
possibility of choosing 0 or 1 vertex and the resulting number of polygons is:
2(p−1)/2 − 1 − p+1
p−1
= 2(p−1)/2 −
.
2
2 Adding the two cases together, we nd:
S = 2(p+1)/2 − p+5
.
2 Plugging-in B and S in our master equation, we nd:
2C − Isolating C we nd: 2p p2 − p + 4
−
p
2p
= (p+1)/2 2 p+5
−
2
+ 1. 2p−1
p2 + p + 2
(p−1)/2
C=
+2
−
.
p
2p Question 5 (20 marks) A wedding organizer needs to sit 4 couples and 4 single persons around a round table. In
how many ways can she sit those 12 people so that:
(a) All couples sit together (the two members of each couple sit side-by-side)? (b) No couple sit together? Hint: Inclusion-Exclusion... Since the table is round, dierent rotations of the same arrangement are indistinguishable, but a clockwise arrangement is distinguishable from its counterclockwise version.
Note: A
D D
B = C C D
A 6= A B C
B Solution:
(a) Let us compute the number N (k) of ways for k couples to sit together, then we will
just need to set k = 4 to answer the question.
To handle the dierent rotations of the table, let us x the position of one of the
four single people, and sit everyone else starting from the right of that person (so
it's like sitting them on a row).
If k couples are to sit together, each of them can have a conguration M F or F M ,
so that's 2 options for each: 2k options.
Once this is decided, we can see each couple as forming a single block, along with the
(11−2k) people that do not belong to any of those k couples. So that's k+(11−2k) =
11 − k blocks to place on a line, and there's (11 − k)! ways to do that.
Therefore, N (k) = 2k (11 − k)!. With k = 4, that's 24 (11 − 4)! = 16 × 7! = 80 640
possibilities. (b) Let Ai be the set of congurations of the table such that the i-th couple sit together,
for i between 1 and 4. If we take the intersection of any k of those sets together,
then the cardinality is the number N (k) calculated in part (a).
The number of congurations that belong to none of those sets Ai is then given by
the inclusion-exclusion formula:
4
X
4
X
4
k 4
(−1)
N (k) =
(−1)
2k (11 − k)!
k
k
k=0
k=0
k = 11! − 4 · 2 · 10! + 6 · 4 · 9! − 4 · 8 · 8! + 16 · 7!
= 18 385 920 . ...

View
Full Document