Let $S$ be a string of $99$ characters, $66$ of which are $A$ and $33$ are $B$. We call $S$ good if, for each $n$ such that $1\le n \le 99$, the sub-string made from the first $n$ characters of $S$ has an odd number of distinct permutations. How many good strings are there? Which strings are good?
Problem
Source: Italian TST 2006 Q1
Tags: induction, Pascal's Triangle, combinatorics unsolved, combinatorics
29.05.2006 06:42
I am pretty sure the one and only "good" string is $64$ $A$'s followed by $32$ $B$'s, and then $AAB$.
29.05.2006 09:36
zgorkster, is it just a guess, or you can prove it? Let's generalize a little bit... Under which conditions, given $a$ and $b$ integers, there is exactly one good string with $a$ "A"s and $b$ "B"s? Is it possible to have $a, b$ such that there is more than one good string?
29.05.2006 11:06
Here's my solution although it's rather long. Your question is very hard I think cmmmrc. I think that a better solution (if there is one) might be required to answer your question. Solution: We must prove the following Lemma: For all $i\in\{1,2,\dots,2^n-1\}$, we have that ${2^n\choose i}$ is even. Proof: By Lucas' Theorem, we have the result immediately: ${2^n\choose i}\equiv {1\choose 0}{0\choose i_k}\dots {0\choose 1}\dots {0\choose i_0}\equiv 0$ mod $2$. where $i=i_k i_{k-1}\cdots i_0$ is the binary representation of $i$. Knowing this, we can begin the problem. Now, the number of distinct permutations of a substring is simply ${n\choose b}$, where $n$ is the length of the substring and $b$ is the number of $B$'s in these $n$ letters. So if a $B$ is in the first $64$ letters, then the number of permutations of the substring with length $64$ is ${64\choose x}$, where $x\in\{1,2,\dots,33\}$. But by our Lemma, the number must be even, and thus the first $64$ letters must all be $A$. Now, there can only be $2$ more $A$'s in the string, so we have three cases. If the $65$th and $66$th letters are both $A$'s, then the rest must be $B$'s. However, if $n=68$, we have ${68\choose 2}$ permutations, which is even. So the first $66$ letters cannot all be $A$'s. Now, if exactly the first $65$ letters are $A$'s, then the $66$th is a $B$ and for $n=66$ we have ${66\choose 1}$ permutations, an even number. Thus the $65$th letter must be $B$. Now comes the tedious part. Now for $x\le 33,$ let $x$ be the number of $B$'s and assume that ${64+x\choose x}$ is odd. Then if we add a $B$ to the sequence, then we have ${65+x\choose x+1}$ permutations, which will remain odd since the greatest power of $2$ dividing $x+1$ divides $65+x$ as well (since $x\le 33$). But if we add an $A$ to the sequence, we have ${65+x\choose x}=\frac{65+x}{65}{64+x\choose x}$ which will remain odd iff $x$ is even. Therefore, we can only add an $A$ if $x$ is even. Now, consider the case that added an $A$ when $x$ is even. By the same method, we can show if ${65+x\choose x}$ is odd (as it should be if $x$ is even), then by adding a $B$ we have ${66+x\choose x+1}=\frac{66+x}{1+x}{65+x\choose x}$ is either not an integer or even. But, if we add an $A$ after the other $A$, we have that ${66+x\choose x}=\frac{66+x}{66}{65+x\choose x}$ is an odd integer iff $x$ is divisible by $4$. So the two $A$'s must be together, and $4|x$. Hence the two $A$'s cannot be the last two of the sequence ($4$ does not divide $33$). Now, we must add a $B$ after the final two $A$'s are gone, but if one $B$ is used, we are still ok, since ${67+x\choose x+1}=\frac{67+x}{1+x}{66+x\choose x}$ which is still odd for $x$ divisible by $4$. However, if we add another $B$ we have that ${68+x\choose x+2}=\frac{68+x}{x+2}{67+x\choose x+1}$ which cannot be even if $4|x$ and ${67+x\choose x+1}$ is odd. Therefore, the only string that works (and barely fits) is the string with $64$ $A$'s, $32$ $B$'s, and finally $AAB$. And finally, its 1 in the morning and if I made any stupid mistakes please correct me. Edit: I changed my proof for the Lemma, it's much simpler & thanks for seeing that mistake cmmmrc
29.05.2006 20:34
Cmmmrc wrote: Let's generalize a little bit... Under which conditions, given $a$ and $b$ integers, there is exactly one good string with $a$ "A"s and $b$ "B"s? Is it possible to have $a, b$ such that there is more than one good string? That's actually quite easy to answer: There is one good string, if {a+b choose a} is odd, and there is no good string, if {a+b choose a} is even. The proof can be done by induction: If {a+b choose a} is even, there is no good string, since the entire string allows an even number of permutations. If x={a+b choose a} is odd, then exactly one of y={a+b-1 choose a} and z={a+b-1 choose a-1} is odd (since y+z=x). Either way you get a unique possibility for extending the string to length a+b. End of proof. Another way of looking at it: You move through the odd entries of Pascal's triangle, downwards, step by step.
29.05.2006 22:22
Nice proof test.
29.05.2006 23:11
Yes. It is basically the same idea I had. I also read carefully zgorkster's and it is correct too. I have found just a typo: somewhere there is a $\binom{66+x}x=\frac{66+x}x \cdot \cdots$ and it should be $\frac{66+x}{66}$, but ...peanuts... the proof holds.