Given an alfabet of $n$ letters. A sequence of letters such that between any 2 identical letters there are no 2 identical letters is called a word. a) Find the maximal possible length of a word. b) Find the number of the words of maximal length.
Problem
Source: Moldavian MO 2006
Tags: induction, combinatorics proposed, combinatorics
20.03.2006 00:28
I'm sure I've misinterpreted at least one of the conditions in some way, but here goes: a) Obviously there can't be four identical letters (in $a \ldots a \ldots a \ldots a$, the outer $a$'s contain the inner $a$'s), so the maximal length is not more than $3n$, but $111222\ldots nnn$ works, so it is $3n$. Is this really it? b) We can order the letters by order of appearance in a word: for example, in $ccbcbabaa$, the first letter to appear is $c$, the second is $b$ and the third is $a$. Given a word, we can permute the kinds of letters in any way (i.e. $(c, b, a)$ to $(a, b, c)$, $(a, c, b)$, $(b, a, c)$, $(b, c, a)$ or $(c, a, b)$), so the result will be a multiple of $n!$. Now suppose that the letters are ordered, so the first to appear is $1$, the second is $2$ and so on (thus losing the $n!$ factor). We'll show that the word begins with $11$. Indeed, it begins with $1$; if there's some letter $a$ between the initial $1$ and the next $1$, then the other two $a$'s must be after the second $1$. If they are after the third $1$ too, then there's a pair of $a$'s that contains a pair of $1$'s, while if one of them is before the third $1$, the first and last $1$'s contain two $a$'s. Thus there's no $a$ between the first two $1$'s and the word begins with $11$. Now calculate $f(1)=1, f(2)=2, f(3)=4$ by hand. We conjecture $f(n)=2^{n-1}$. To prove it by induction, assume this is the case for $n-1$. Given a word of length $n$, remove the three $1$'s; the resulting sequence is a word, and it is a word of length $3n-3$, so it must begin with $22$. It now follows that the original word began with $11122$ or $112122$ (the third $1$ can't be after two or more $2$'s), and this is also enough for the word to be valid. Thus the number of words is, in total, $n! \times 2^{n-1}$.
20.03.2006 01:44
Yes, that's it. I think this question is not original, however -- it has appeared on the forum here, labeled MOP homework from 2002.