Once again, a very large crowd of monkeys is sitting at typewriters with 26 letter keys.
Each monkey types a string of letters at random. It turns out that almost exactly half of the monkeys has typed a string in which the same letter occurs three (or more) times in a row, as in . The other half of the monkeys typed a string in which no letter occurs more than twice in a row, as in .
Determine .
Inspiration: A problem idea by David Fairer.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Consider an alphabet of α letters and a string of length n . We call a string valid if it does not have three or more of the same letter in a row. Let X n be the number of valid strings of length n .
Obviously, all strings of lengths less than 3 are valid: X 1 = α ; X 2 = α 2 ; each valid string of length n ≥ 3 is generated by
either taking a valid string of length n − 1 and adding a letter unequal to the last letter, e.g. O L D ↦ O L D N ; there are α − 1 ways to choose the new letter.
or taking a valid string of length n − 2 and adding twice a letter unequal to the last letter, e.g. O L ↦ O L N N ; there are α − 1 ways to choose the new letter.
Thus X n = ( α − 1 ) X n − 1 + ( α − 1 ) X n − 2 and To solve this recurrence relation, try a function of the form X n = p n . Then p 2 = ( α − 1 ) p + ( α − 1 ) ; p ± = 2 1 ( α − 1 ) ± 2 1 ( α + 1 ) 2 − 4 . The general solution of the recurrence relation is any linear combination of these solutions, i.e. X n = A + p + n + A − p − n .
From X 1 = α and X 2 = α 2 we find that A ± = 2 ( α − 1 ) α ± 2 ( α + 1 ) 2 − 4 α .
However, it can be shown that the second term is always less than one half: ∣ A − p − n ∣ < 2 1 . Thus, we may simply round to an integer: X n = [ A + p + n ] = [ ( 2 ( α − 1 ) α + 2 ( α + 1 ) 2 − 4 α ) ( 2 1 ( α − 1 ) + 2 1 ( α + 1 ) 2 − 4 ) n ] .
Now we must calculate for which value N , X N ≈ f α N . The equation takes the form A + p + N ≈ f α N ; The solution is N ≈ lo g p + − lo g α lo g f − lo g A + . Substituting α = 2 6 , f = 0 . 5 , we find N ≈ lo g 2 5 . 9 6 2 9 1 2 − lo g 2 6 lo g 0 . 5 − lo g 1 . 0 0 2 8 0 7 8 = 4 8 7 . 5 4 ; the monkeys type strings of 487 or 488 letters. (The fraction of valid strings will be 50.04% and 49.97%, respectively.) The answer to the problem is thus ⌊ N / 1 0 ⌋ = 4 8 .