I want to make sequences of length exactly 3r (r is a natural number, including zero). How many sequences are there such that each sequence is 3r characters long, with at least r of the same character in a row? Any permutation of these characters are valid. There are 25 characters and I can use each character as many times as I want.
how many sequences given the conditions: length exactly 3r, at least r of the characters in a row are the same.
-
0Wait... "*in A row*" or "*in THE row*"? These two phrases have pretty different meanings. With $r=3$ do you consider $\color{red}{a}bc\color{red}{a}de\color{red}{a}fg$ to be a valid string that you want to count? $a$ occurs exactly three times in *the* row (*i.e. in the string*)... but not consecutively (*i.e. in a row*). Or do you only want to count things like $\color{red}{aaa}bcdefg$ – 2017-02-18
-
0in A row, so abcadeafg does not count, But we can count aaabcdefg or asdcccasd counts, given that r = 3. – 2017-02-18
2 Answers
The method will be to count sequences length $3r$ which have $
By symmetry each of the generating functions for sequences ending "a", "b", "c" etc are equal
$$f_a(x)=f_b(x)=f_c(x)=\ldots =f_y(x)=\frac{f(x)(x-x^{r})}{1-x^r}$$
therefore
$$f(x)=1+25\cdot\frac{f(x)(x-x^{r})}{1-x^r}\\\Rightarrow f(x)=\frac{1}{1-25\frac{(x-x^{r})}{1-x^r}}\\\Rightarrow f(x)=\frac{1-x^r}{1-(25x-24x^r)}$$
Then the number of sequences length $3r$ with less than $r$ successive identical characters is the $x^{3r}$ coefficient of $f(x)$, in other words
$$C_{
-
1very good approach (+1) – 2017-02-19
-
0what does the x represent in this function. – 2017-02-23
-
0It doesn't represent anything. It is known as an "indeterminate". In other words we use the formal power series purely for the coefficients in front of the powers of $x$. Sometimes [generating functions](https://en.m.wikiversity.org/wiki/Introduction_to_generating_functions) are referred to as a "clothesline" upon which we hang the coefficients we are interested in. In this case the generating function I have derived has coefficients of $x^k$ which count words of length $k$ with less than $r$ consecutive identical characters. – 2017-02-23
-
0For the case of $k=3r$ the coefficient of $x^{3r}$ in this expansion is then subtracted from the total number of words length $3r$ i.e. from $25^{3r}$. At the end of Markus' answer he has derived the generating function for *desired words* by subtracting my generating function from the generating function that enumerates all possible words $(1-25x)^{-1}$. Both answers amount to the same thing but Markus' has better formatting :) – 2017-02-23
Here is another approach to derive sequences of length $3r$ which contain $r$ consecutive equal characters. We start with a generating function for words of a $25$ character alphabet which counts words with no consecutive equal characters at all.
These words are called Smirnov or Carlitz words. See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information.
The generating function $A(z)$ counting Smirnov words over a $25$ character alphabet is according to the reference \begin{align*} A(z)=\left(1-\frac{25z}{1+z}\right)^{-1} \end{align*}
The coefficient of $z^n$ of $A(z)$ gives the number of Smirnov words of length $n$.
Based upon $A(z)$ we generate all words over the $25$ character alphabet which contain no more than $r-1$ consecutive equal characters. This means each character can be replaced with one up to $r-1$ characters.
\begin{align*} z\longrightarrow z+z^2+z^3+\cdots+z^{r-1}=\frac{z(1-z^{r-1})}{1-z} \end{align*} in the generating function $A(z)$.
We obtain this way a generating function $B(z)=A\left(\frac{z(1-z^{r-1})}{1-z}\right)$ with \begin{align*} B(z)&=\left(1-\frac{25\cdot \frac{z(1-z^{r-1})}{1-z}}{1+\frac{z(1-z^{r-1})}{1-z}}\right)^{-1}=\frac{1-z^r}{1-25z+24z^r}\\ \end{align*} in accordance with the answer of @N.Shales.
$$ $$
We conclude a generating function $C(z)$ which counts words over a $25$ character alphabet each having at least $r$ consecutive equal characters is \begin{align*} C(z)&=\sum_{n=0}^\infty (25z)^n-B(z)\\ &=\frac{1}{1-25z}-\frac{1-z^r}{1-25z+24z^r} \end{align*} The number of wanted words is therefore $$[z^{3r}]C(z)$$
-
0Great work (+1)! – 2017-02-23
-
1@N.Shales: This also holds for your answer of course! (+1) – 2017-02-23