You are on page 1of 3

MATH 302:201 Homework Assignment 2 Due 2022-01-24

Upload your solutions on Canvas as a single PDF file before midnight on the due date. Late assignments
will likely not be graded. Please indicate on the first page which questions you have solved.

1. How many anagrams (rearrangements of letters) are there of the word “MATHEMATICS”?

2. We toss a regular 6-sided die 4 times in a row.


(a) What is the probability that no result is repeated?
(b) What is the probability that every throw is strictly larger than the previous one?

3. An instructor gives 4 math courses every year during a span of 10 years. In each course, he tells
three jokes to the students. What is the least amount of jokes the instructor must know if he does
not want to tell exactly the same set of three jokes in two separate courses?

4. A simple substitution cipher is formed by scrambling the alphabet so that every letter in the plaintext
corresponds to a particular letter in the ciphertext. For instance, A is replaced by Q, B by H, C
by A, and so on. Let’s say we want to solve such a cipher using brute force, that is, systematically
trying one option at a time until we find the correct one.
(a) How many possible cipher keys are there in total to try? We assume that the English alphabet
(26 letters) is being used for the cipher.
(b) How large is the number in (a)? Imagine that every person on Earth (about 7.9 billion) had
a computer that is able to check one million possible cipher keys every second (in a somehow
universally coordinated attempt). About how long time (in years) would it take to check all
the possibilities?
Lesson: Brute force is not a good way to solve a substitution cipher. To actually solve one, see the
last page instead.

5. Consider the following game: An urn contains 10 white balls and 5 black balls. You can draw a
number of balls from the urn (without replacement). For each white ball drawn you get $1, but for
each black ball you lose $2.
(a) You decide to draw 6 balls from the urn. What is the probability that you will break even, i.e.
neither win nor lose money on the game?
(b) You decide to draw 6 balls from the urn. Are you more likely to win money or lose money on
the game?
(c) Write an expression for the probability of winning money on the game when you decide to
draw n balls from the urn. How many balls should you choose to draw in order to maximize
your probability of winning? (Use a computer.)
Additional problems (no need to hand in).

1. Compute (and compare) the probabilities of obtaining the various poker hands when dealt a hand
of five cards from an ordinary 52-card deck.
(a) Straight flush 5 cards in same suit and of consecutive rank∗
(b) Four of a kind 4 cards of same rank
(c) Full house 3 cards of same rank + 2 cards of same rank
(d) Flush 5 cards in same suit
(e) Straight 5 cards of consecutive rank∗
(f) Three of a kind 3 cards of same rank
(g) Two pair 2 cards of same rank + 2 cards of same (other) rank
(h) One pair 2 cards of same rank
(i) High card none of the above

2. A white queen and a black king are placed randomly on an 8×8 chessboard. What is the probability
that the king is in check? (In other words, the probability that the king is in the same row, column
or diagonal line as the queen.)

3. More exercises in the textbook, in particular Chapter 1 exercises 5–8 and 13–15.


An ace (A) can be used both as number 1 or as the card above K, but a straight cannot “loop” as in Q–K–A–2–3.
Definitively extra (not very much math, but could be fun to do anyway).

4. If you have done Question 4 correctly, you should have seen that the brute force approach is very
unlikely to succeed in solving a simple substitution cipher. Nevertheless, this is not a very secure
encryption method, and the cipher can often be solved without much trouble. How?
Note that any given letter in the ciphertext precisely matches one letter in the plaintext. Therefore,
common letters in the ciphertext will correspond to common letters in the actual message, and
likewise for uncommon ones. This means that we can compute the letter frequencies and use them
to find the cipher key.
In an average English text, the most frequent letters are E, T, A, O, I, N, and so on (in that order).
These will likely match the most common letters in the ciphertext. Likewise, uncommon letters such
as X, Q and Z should likely match letters that are very rare or not found at all in the ciphertext.
For a full list of letter frequencies in English (and many other languages), see the Wikipedia page.

When arriving at a hotel, Mr. Underhill receives a letter with the following cryptic message:

GKK RZGR NS QWKT TWUS DWR QKNRRUV.


DWR GKK RZWSU XZW XGDTUV GVU KWSR.
RZU WKT RZGR NS SRVWDQ TWUS DWR XNRZUV.
TUUP VWWRS GVU DWR VUGOZUT LE RZU JVWSR.
JVWB RZU GSZUS G JNVU SZGKK LU XWMUD.
G KNQZR JVWB RZU SZGTWXS SZGKK SPVNDQ.
VUDUXUT SZGKK LU LKGTU RZGR XGS LVWMUD.
RZU OVWXDKUSS GQGND SZGKK LU MNDQ.

To decrypt the message, do the following:

• Copy the text above and compute the letter frequencies using e.g. this online tool.
• Compare with the list of most common letters in English and note which ones are the most
frequent.
• In a word processor, start replacing letters one at a time using the “Find & Replace” tool,
beginning with the most frequent ones (since you are most likely to get those right).
• Note: you need to distinguish between letters that are still part of the ciphertext and letters
that are already substituted. The easiest way is to use uppercase letters for the cipher and
always replace them with lowercase letters for the plaintext. Remember to check the “Match
case” option in the replace function!
• There is not necessarily a one-to-one correspondence between the two lists of frequencies, so
you have to make guesses and might even need to backtrack sometimes. However, if you get
a few letters right you can begin to recognize some of the words, and that can help you make
more guesses. Pay attention to the letter combinations formed and see if they seem plausible.
Usually it is helpful to look at words that have only a few unknown letters, so start by looking
at the short words.
• When all the text is correct English, you know that you have encrypted the message.

You might also like