Maths Olympiad Prep

Library / /74 of 91

, 2007

Combinatorics Difficulty 7.1 National Olympiad, round 2 Prove it India

Given a finite string SS of symbols XX and OO, we write Δ(S)\Delta(S) for the number XX's in SS minus the number of OO's. (For example, Δ(XOOXOOX)=1\Delta(XOOXOOX) = -1.) We call a string SS balanced if every sub-string TT of (consecutive symbols) SS has the property 1Δ(T)2-1 \le \Delta(T) \le 2. (Thus XOOXOOXXOOXOOX is not balanced, since it contains the sub-string OOXOOOOXOO whose Δ\Delta-value is 3-3.) Find, with proof, the number of balanced strings of length nn.

Solution

The balanced strings consists of XX's and OO's arranged alternately, or with as many as two consecutive letters of the same kind. Such occurrences of double letters must happen alternately with an even number (possibly zero) of single letters between any two double occurrence. If bnb_n is the number of balanced strings of length nn, we show that
bn+2=2bn+2. b_{n+2} = 2b_n + 2.
For n=1n=1, we have the strings XX and OO, so that b1=2b_1 = 2. For n=2n=2, the balanced strings are XXXX, XOXO, OXOX, OOOO so that b2=4b_2 = 4. Similarly, we have for n=3n=3 the balanced strings XXOXXO, XOXXOX, XOOXOO, OXXOXX, OXOOXO, OOXOOX, giving b3=6b_3 = 6. However, for n=4n=4, we see that the strings are XXOXXXOX, XXOOXXOO, XOXXXOXX, XOXOXOXO, XOOXXOOX, OXXOOXXO, OXOXOXOX, OXOOOXOO, OOXXOOXX, OOXOOOXO and hence b4=10b_4 = 10.
Let xn,yn,znx_n, y_n, z_n respectively denote the number of balanced strings of length nn that end with XXXX; that end with XOXO and whose last occurrence of a double letter was XXXX; and that end with XOXO, but whose last occurrence of a double letter was OOOO. Note that XX and OO can be interchanged

in any balanced string. Hence xn,yn,znx_n, y_n, z_n also denote the number of balanced strings of length nn that end with OOOO; that end with OXOX and whose last occurrence of a double letter was OOOO; and that end with OXOX, but whose last occurrence of a double letter was XXXX. This shows that bn=2xn+2yn+2zn2b_n = 2x_n + 2y_n + 2z_n - 2 (we count purely alternating strings XOXO...XOXOXO... XO and OXOX...OXOXOX... OX twice; once among yny_n and once among znz_n). Thus bn+2=2(xn+yn+zn)b_n + 2 = 2(x_n + y_n + z_n). We can form the strings of length n+2n+2 from such string of length nn in exactly the following ways;
(i) if already ending with XXXX, we may add either OOOO or OXOX, but nothing else;
(ii) if ending with XOXO, with last double occurrence XXXX, we can add OXOX or XOXO, but nothing else;
(iii) if ending with OXOX, with last double occurrence OOOO, we can add XOXO or OXOX, but nothing else.
This gives 2(xn+yn+zn)2(x_n + y_n + z_n) strings. Similarly, by interchanging XX and OO, we get 2(xn+yn+zn)2(x_n + y_n + z_n) more strings. Thus
bn+2+2=4(xn+yn+zn)=2(bn+2). b_{n+2} + 2 = 4(x_n + y_n + z_n) = 2(b_n + 2).
Using the initial conditions, we get
b2n=22n2,b2n1=2n+12. b_{2n} = 2 \cdot 2^n - 2, \quad b_{2n-1} = 2^{n+1} - 2.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.