[Math] Monkey typing on 29 letter keyboard.

combinatoricsprobability

This monkey is driving me a little crazy. I think he should get fired – it's not nice.

Here is the information.
A monkey is typing on a 29 letter keyboard. He is writing a word that is 5 letters long.

  • How many words can the monkey write? 29*29*29*29*29
  • What is the probability the monkey starts with the letter H? 1/29
  • What is the probability the monkey writes the word "YASOV"?
    1/29*29*29*29*29
  • What is the probability the word contains "H" once?

I don't understand the last one. My best bet would have been 29*29*29*29*1/29^5.
The mindset being that you can press every key (4 times), and then press H once.

Or maybe even 29*29*29*29*29-29*29*29*29*28.

Doing a baby calculation with a keyboard of ABC, and the monkey typing a word of two letters, containing the word "A" only once I get 4/9. I just scribbled every possibility and found the answer, so I assume: 2*2/3*3. I don't see the connection to the 5 in the answer.

I also don't understand why 28 (or 2 for that matter), as 28 would mean 28 possibilities. Wouldn't that be the possibility of not getting H? Every possibility except H?

The correct solution to the real answer is 28^4*5/29^5.

Best Answer

"What is the probability the word contains "H" once?"

This is slightly ambiguous. Do you mean the word i) contains at least one H or ii) contains exactly one H?

i) has a trick. There are are $29^5$ total words. There are $28^5$ words that contain no H's whatsoever (-- each letter can be any one of the remaining 28 letters). So there are $29^5 - 28^5$ words that have one or more Hs.

ii) there is a naive way and a sophisticated way. First the naive way: There are $1*28*28*28*28$ ways to type a five letter word a five letter word starting with H and the rest of the letters are not H. There are $28*1*28*28*28$ ways to type a word where the 2nd letter is H but the rest are not H. There are $28*28*1*28*28$ where the third letter is H and so on.

So in total there are $1*28*28*28*28 + 28*1*28*28*28 + ..... + 28*28*28*28*1 = 5*28^4$.

... or the sophisticated way: The number of ways to type a 5-letter word where a specific letter slot must be H and the remaining 4 letter slots must not be H is $1$ for the dedicated letter slot and $28^4$ for the remaining 4 letters slot (each of which can be any of the 28 remaining letters remaining). That is $28^4$ possible ways. Now there are 5 possible choices for which dedicated letter slot is the H. That means there are $5*28^4$ possible words. (5 choices for which letter is the H-- and 28 choices for each of the remaining four letters. Multiply the choices... $5*28^4$.

====

" 2*2/3*3. I don't see the connection to the 5 in the answer"

If you need to figure out $n$ letter word with $m$ choices of letters the number of words with exactly one ~ is $n*(m-1)^{n-1}$. So the answer with 3 letters and a 3 letter word is $3*(2)^{2} = 12$ [ABB,ABC, ACB,ACC, BAB,BAC, CAB,CAC, BBA,BCA,CBA,CCA].

One 2 corresponds the 28. The other to the 4. The 3 corresponds to the 5.

====

Two post-scripts.

I just realized I gave the answers to "What is the NUMBER OF WAYS" rather than "What is the probability".

Well, Probability of Event = (Number of Ways Event can Happen)/(Number of total things that can happen).

So for i) Number of ways to get at least one H = $29^5 - 28^5$. Number of total things that can happen = $29^5$.

So probability is $(29^5 - 28^5)/29^5 = 1 - (28/29)^5$.

for ii) Number of ways to get exactly one H = $5*28^4$. Number of total things that can happen = $29^5$ so probability is $5*28^4/29^5$.

For your 3 letters and a three letter word: Number of ways to get exactly one A = $3*2^2 = 12$. Total ways to type three letters = $3^3 = 27$.

So probability = $3*2^2/3^3 = 2^2/3^2$. Note: because you had 3 letters total and 3 letter length words one of the 3s cancelled. Which is probably why you didn't see the corespondence.

If you had say a four letter word of ABC with exactly one A then the total ways would be $4*2^3/3^4$. (Do you see why) and no canceling. That you chose the same number of letters and length of words was a misleading coincidence.

2nd postcript as per aarons comment.... well, I have to go cook dinner now. I'll get to it later but... It's to introduce the idea of choicing m out of n options. i.e. how to choice which position the one H is. Or if you had to calculate the probability of a five letter word with exactly TWO Hs--- how to choice which of the 5 positions we can place the 2 Hs....

Think about it. I'll get back to it.

Related Question