Maths Olympiad Prep

Library / /29 of 30

, 2022

Combinatorics Difficulty 4.1 AIME Prove it Canada

A Bauman string is a string of letters that satisfies
the following two conditions.

Each letter in the string is AA, BB, CC, DD, or EE.
No two adjacent letters in the string are the same.

For example, AECDAECD and BDCECBDCEC are Bauman strings of length 4 and
length 5, respectively, and ABBCABBC
and DAEEEDAEEE are not Bauman
strings.

How many Bauman strings of length 5 are
there in which the first letter and the last letter are both AA?
Determine the number of Bauman strings of
length 6 that contain more than one BB.
Determine the number of Bauman strings of
length 10 in which the first letter is CC and the last letter is DD.

Solution

Solution 1

For each Bauman string of length 5 in which the first and last
letters are both AA, the second and
fourth letters are not AA.

For such Bauman strings, either the third letter is AA, or the third letter is not AA.

Case 1: The third letter is AA.

In this case, the string is of the form AAAA\underline{\hspace{5mm}}A\underline{\hspace{5mm}}A.

There are 4 choices for the second letter (B,C,DB,C,D, or EE) and 4 choices for the fourth letter,
and so there are 4×4=164\times4=16 such
Bauman strings.

Case 2: The third letter is not AA.

In this case, the string is of the form AxAA\underline{\hspace{5mm}}x\underline{\hspace{5mm}}A, where the
third letter xx is B,C,DB,C,D, or EE, and so there are 4 choices for the
third letter.

The second letter must be different than the third letter and must not
be AA, and so there are 3 choices
for the second letter.

Similarly, there are 3 choices for the fourth letter, and so there are
4×3×3=364\times3\times3=36 such Bauman
strings.

In total, the number of Bauman strings of length 5 in which the first
and last letters are both AA is
16+36=5216+36=52.

Solution 2

For each Bauman string of length 5 in which the first and last
letters are both AA, either the
second and fourth letters are the same, or they are different.

Case 1: The second and fourth letters are the same.

In this case, the string is of the form AxxAAx\underline{\hspace{5mm}}xA.

There are 4 choices for the second letter (B,C,DB,C,D, or EE) and 1 choice for the fourth letter
since it is the same as the second letter.

The third letter must be different than the second and fourth letters
(which are the same) and so there are 4 choices for the third
letter.

Thus, there are 4×1×4=164\times1\times4=16
such Bauman strings.

Case 2: The second and fourth letters are different.

In this case, the string is of the form AxyAAx\underline{\hspace{5mm}}\, yA, where xx and yy represent different letters.

There are 4 choices for the second letter (B,C,DB,C,D, or EE) and 3 choices for the fourth letter
(it is different than the second letter and not AA).

The third letter must be different than the second and fourth letters
(which are different) and so there are 3 choices for the third
letter.

Thus, there are 4×3×3=364\times3\times3=36
such Bauman strings.

In total, the number of Bauman strings of length 5 in which the first
and last letters are both AA is
16+36=5216+36=52.
Solution 1

We may determine the number of Bauman strings of length 6 that
contain more than one BB
indirectly.

That is, we may subtract the number of Bauman strings that contain 0
BB’s and the number of Bauman
strings that contain exactly 1 BB
from the total number of Bauman strings of length 6.

For a Bauman string of length 6 (with no restrictions), there are 5
choices for the first letter and 4 choices for each of the remaining
letters, and so there are a total of 5×45=51205\times4^5=5120 such strings.

For a Bauman string of length 6 that contains 0 BB’s, there are 4 choices for the first
letter and 3 choices for each of the remaining letters, and so there are
a total of 4×35=9724\times3^5=972 such
strings.

Next, we count the number of Bauman strings that contain exactly 1
BB.

If the first letter of the string is a BB, then there are 4 choices for the
second letter and 3 choices for each of the remaining four
letters.

Similarly, if the last letter is a BB, then there are 4 choices for the
letter adjacent to the BB and 3
choices for each of the remaining four letters.

Thus, there are 1×4×34=3241\times4\times3^4=324 strings that begin
with a BB and 324 strings that end
with a BB.

If the second letter of the string is a BB, then there are 4 choices for the first
letter, 4 choices for the third letter, and 3 choices for each of the
fourth, fifth and sixth letters.

Thus, there are 4×1×4×33=4324\times1\times4\times3^3=432 such
strings.

Similarly, if the third, fourth or fifth letter in the string is a BB, then there are 432 such strings.

In total, there are 51209722×3244×432=17725120-972-2\times324-4\times432=1772
Bauman strings of length 6 that contain more than one BB.

Solution 2

A Bauman string of length 6 cannot contain more than 3 BB’s (confirm for yourself why this is
true before proceeding).

We may determine the number of Bauman strings of length 6 that contain
more than one BB directly.

That is, we may count the number of strings that contain exactly 3 BB’s and the number of strings that
contain exactly 2 BB’s.

Thus, there are two cases to consider.

Case 1: The Bauman string has exactly 3 BB’s

In this case, the string must take one of four possible forms: BBB,  BBB,  BBB,  BBB.B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}},~~ B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B ,~~ B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B ,~~ \underline{\hspace{5mm}}\,B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B. We begin by counting the number of strings of the form
BBBB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}.

There are 4 choices for the second letter (A,C,DA,C,D, or EE), 4 choices for the fourth letter, and
4 choices for the sixth letter, and so there are 43=644^3=64 such strings.

Similarly, there are 43=644^3=64 strings
of the form BBB\underline{\hspace{5mm}}\,B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B.

It is worth noting that BBBB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}} and $BB\$\underline{\hspace{5mm}}\,B\underline{\hspace{5mm}}B\underline{}
}B$ have identical forms when one is read left to right and the
other right to left.

We may call such pairs of forms symmetric, and recognize that
under the same restrictions, symmetric forms have an equal number of
Bauman strings.

For strings of the form BBBB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B, there are 4 choices for the
second letter, 4 choices for the fourth letter, and 3 choices for the
fifth letter (since the fifth letter must be different than BB and different than the fourth letter,
which is not BB), and so 42×3=484^2\times3=48 such strings.

Since BBBB\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B is symmetric to BBBB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B, there are similarly 42×3=484^2\times3=48 strings of this form.

Thus, there are 2×64+2×48=2242\times64+2\times48=224 Bauman strings
with exactly 3 BB’s.

Case 2: The Bauman string has exactly 2 BB’s

In this case, the string must take one of ten possible forms.

Eight of these occur in one of the following four symmetric pairs BB  and  BB,       BB  and  BB,B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}} \textrm{ \ and \ } \underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B \textrm{,\ \ \ \ \ \ \ } B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}} \textrm{ \ and \ } \underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B,
BB  and  BB,       BB  and  BBB\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{ }B\underline{\hspace{5mm}} \textrm{ \ and \ } \underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B \textrm{,\ \ \ \ \ \ \ } \underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}} \textrm{ \ and \ } \underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}} and
the final two forms (which are not a symmetric pair) are BB  and  B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B \textrm{ \ and \ } BB.\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}. We begin by counting the number of strings of
the form BBB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}.

There are 4 choices for the second letter (A,C,DA,C,D, or EE), 4 choices for the fourth letter,
3 choices for each of the fifth and sixth letters, and so there are
42×32=1444^2\times3^2=144 such
strings.

Similarly, there are 42×32=1444^2\times3^2=144 strings for each of the
next five forms listed above, $BB,BB,BB,\$\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B,\, B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,, \,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B, \, BB,B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,, \textrm{} and }
BB$.\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\$.

For strings of the form BB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}, there are 4
choices for the first letter, 4 choices for the third letter, 4 choices
for the fifth letter, and 3 choices for the sixth letter, and so there
are 43×3=1924^3\times3=192 such
strings.

Since BB\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}} is symmetric to BB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}, there are similarly 43×3=1924^3\times3=192 strings of this form.

Finally, there are 4×33=1084\times3^3=108 strings of the form BBB\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B, and 43×3=1924^3\times3=192 strings of the form BB\underline{\hspace{5mm}}B\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}B\underline{\hspace{5mm}}.

Thus, there are $6×144+2×192+\$6\times144+2\times192+
108+192 =1548 Bauman strings with exactly 2 B$’s.

In total, there are 224+1548=1772224+1548=1772 Bauman strings of length 6
that contain more than one BB.
Solution 1

Consider all Bauman strings of length nn that begin with CC.

There are 4 choices for each of the remaining n1n-1 letters, and so there are 4n14^{n-1} such Bauman strings.

Each of these strings either ends with DD, or it does not end with DD.

We call those that end with DD,
dnd_n, and we define dn|d_n| to be the number of such
strings.

Similarly, we call those that do not end in DD, xnx_n, and we define xn|x_n| to be the number of such
strings.

For example, d1d_1 represents the
Bauman strings of length 11 that
begin with CC and end with DD, and since no such string exists, then
d1=0|d_1|=0.

Similarly, x1x_1 represents the
Bauman strings of length 11 that
begin with CC and do not end with
DD, and so x1=1|x_1|=1 (the string is CC).

We may confirm that 4n1=dn+xn4^{n-1}=|d_n|+|x_n| when n=1n=1, since 411=d1+x1=0+14^{1-1}=|d_1|+|x_1|=0+1.

Further, we know that d2=1|d_2|=1 (the
string is CDCD), and x2=3|x_2|=3 (the strings are CACA, CBCB, CECE), and again confirm that 421=1+34^{2-1}=1+3.

Next, consider the Bauman strings of length nn that begin with CC and do not end with DD, that is, xnx_n.

Each of these strings could have a DD added to its end to form a Bauman
string of length n+1n+1 that begins
with CC and ends with DD, or dn+1d_{n+1}.

Since adding a DD to the end of
every string xnx_n gives all possible
strings dn+1d_{n+1}, then dn+1=xn|d_{n+1}| = |x_n|.

From our earlier work, we may confirm that d2=x1=1|d_2|=|x_1|=1.

Further, $|x_{n+1}| = 4|d_n| +
3|x_n|$. Why is this true?

Every Bauman string of length n+1n+1
that begins with CC and does not end
with DD, that is xn+1x_{n+1}, is either a string dnd_n with an AA, BB, CC, or EE added to its end, or it is a string
xnx_n that has a choice of 3 letters
added to its end (the letter added can not be DD and it can not be the last letter of
xnx_n, leaving 3
possibilities).

The number of strings dnd_n that have
AA, BB, CC, or EE added to its end is 4dn4|d_n|.

The number of strings xnx_n that have
a choice of 3 letters added to its end is 3xn3|x_n|.

Therefore, we conclude that $|x_{n+1}| =
4|d_n| + 3|x_n|$.

From our earlier work, we may confirm that x2=4d1+3x1=4(0)+3(1)=3|x_2|=4|d_1|+3|x_1|=4(0)+3(1)=3.

We use these two formulas $|d_{n+1}| =
|x_n|and and |x_{n+1}| = 4|d_n| +
3|x_n|,whichareequivalentto, which are equivalent to |d_{n}| = |x_{n-1}|and and |x_{n}| = 4|d_{n-1}| + 3|x_{n-1}|$, to
build the table below.

nn
dn=xn1|d_n|=|x_{n-1}|
xn=4dn1+3xn1|x_n|=4|d_{n-1}| + 3|x_{n-1}|

1
d1=0|d_1|=0
x1=1|x_1|=1

2
d2=1|d_2|=1
x2=3|x_2|=3

3
d3=x2=3|d_3|=|x_{2}|=3
$|x_3|=4|d_{2}| +
3|x_{2}|=4(1)+3(3)=13$

4
d4=x3=13|d_4|=|x_{3}|=13
$|x_4|=4|d_{3}| +
3|x_{3}|=4(3)+3(13)=51$

5
d5=51|d_5|=51
x5=4(13)+3(51)=205|x_5|=4(13)+3(51)=205

6
d6=205|d_6|=205
x6=4(51)+3(205)=819|x_6|=4(51)+3(205)=819

7
d7=819|d_7|=819
x7=4(205)+3(819)=3277|x_7|=4(205)+3(819)=3277

8
d8=3277|d_8|=3277
x8=4(819)+3(3277)=13107|x_8|=4(819)+3(3277)=13\,107

9
d9=13107|d_9|=13\,107
x9=4(3277)+3(13107)=52429|x_9|=4(3277)+3(13\,107)=52\,429

10
d10=52429|d_{10}|=52\,429
not needed

Therefore, the number of Bauman strings of length 1010 in which the first letter is CC and the last letter is DD is 52 429.

Solution 2

Let SnS_{n} be the set of Bauman
strings of length nn in which the
first letter is CC and the last
letter is DD.

Further, we define Sn|S_{n}| to be
the number of such strings.

For example, S2={CD}S_2=\{CD\} and so
S2=1|S_{2}|=1, and S3={CAD,CBD,CED}S_3=\{CAD, CBD, CED\} and so S3=3|S_{3}|=3.

Each string in S10S_{10} is of the
form CDC\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,\underline{\hspace{5mm}}\,D or CT8DCT_8D where T8T_8 is a Bauman string of length 8 that
does not begin with CC and does not
end with DD.

Therefore, S10=T8|S_{10}|=|T_8|. The
number of such strings, T8|T_8|, is
equal to the total number of Bauman strings of length 8the number of Bauman strings of length 8 that begin with Cthe number of Bauman strings of length 8 that end with D+the number of Bauman strings of length 8 that begin with C and end with D\begin{array}{cl} & \text{the total number of Bauman strings of length 8}\\ - & \text{the number of Bauman strings of length 8 that begin with } C\\ - & \text{the number of Bauman strings of length 8 that end with } D\\ + & \text{the number of Bauman strings of length 8 that begin with } C \text{ and end with } D \end{array} In the above, we note that strings beginning with
CC include those that end with DD, as well as others.

Similarly, strings that end with DD
include those that begin with CC, as
well as others.

Since we have subtracted the number of strings that begin with CC and end with DD twice from the total, we conclude by
adding the number of such strings.

For a Bauman string of length 8, there are 5 choices for the first
letter and 4 choices for each of the remaining 7 letters.

Thus, the total number of Bauman strings of length 8 is equal to 5×475\times4^7.

For a Bauman string of length 8 that begins with CC, there is 1 choice for the first letter
and 4 choices for each of the remaining 7 letters.

Thus, the total number of Bauman strings of length 8 that begin with
CC is equal to 1×471\times4^7.

Also, the total number of Bauman strings of length 8 that end with DD is equal to 1×471\times4^7.

The number of Bauman strings of length 8 that begin with CC and end with DD is equal to S8|S_8|.

Therefore, we get S10=T8=5×471×471×47+S8=3×47+S8|S_{10}|=|T_8|=5\times4^7-1\times4^7-1\times4^7+|S_8|=3\times4^7+|S_8|
and so the number of Bauman strings of length 10 that begin with CC and end with DD is dependent on the number of Bauman
strings of length 8 that begin with CC and end with DD.

At this point, we could repeat the process above to determine S8|S_8|, however it may be more efficient
to generalize the work above to determine a formula for Sn|S_n|.

For integers n3n\geq3, each string
in SnS_{n} is of the form CTn2DCT_{n-2}D where Tn2T_{n-2} is a Bauman string of length
n2n-2 that does not begin with CC and does not end with DD.

The number of such strings, Tn2|T_{n-2}|, is equal to the total number of Bauman strings of length n2the number of Bauman strings of length n2 that begin with Cthe number of Bauman strings of length n2 that end with D+the number of Bauman strings of length n2 that begin with C and end with D\begin{array}{cl} & \text{the total number of Bauman strings of length } n-2\\ - & \text{the number of Bauman strings of length } n-2 \text{ that begin with } C\\ - & \text{the number of Bauman strings of length } n-2 \text{ that end with } D\\ + & \text{the number of Bauman strings of length } n-2 \text{ that begin with } C \text{ and end with } D \end{array} For a Bauman string of length n2n-2, there are 5 choices for the first
letter and 4 choices for each of the remaining n3n-3 letters.

Thus, the total number of Bauman strings of length n2n-2 is equal to 5×4n35\times4^{n-3}.

For a Bauman string of length n2n-2
that begins with CC, there is 1
choice for the first letter and 4 choices for each of the remaining
n3n-3 letters.

Thus, the total number of Bauman strings of length n2n-2 that begin with CC is equal to 1×4n31\times4^{n-3}.

Also, the total number of Bauman strings of length n2n-2 that end with DD is equal to 1×4n31\times4^{n-3}.

The number of Bauman strings of length n2n-2 that begin with CC and end with DD is equal to Sn2|S_{n-2}|.

Therefore, we get Sn=Tn2=5×4n31×4n31×4n3+Sn2=3×4n3+Sn2, for integers n3.|S_{n}|=|T_{n-2}|=5\times4^{n-3}-1\times4^{n-3}-1\times4^{n-3}+|S_{n-2}|=3\times4^{n-3}+|S_{n-2}|, \textrm{ for integers } n\geq3. Using this recursive formula
and the fact that S2=1|S_2|=1, we get
S4=3×443+S42=3×4+S2=13S6=3×463+S62=3×43+S4=205S8=3×483+S82=3×45+S6=3277S10=3×4103+S102=3×47+S8=52429\begin{array}{lllllll} |S_4|&=&3\times4^{4-3}+|S_{4-2}|&=&3\times4+|S_2|&=&13\\ |S_6|&=&3\times4^{6-3}+|S_{6-2}|&=&3\times4^3+|S_4|&=&205\\ |S_8|&=&3\times4^{8-3}+|S_{8-2}|&=&3\times4^5+|S_6|&=&3277\\ |S_{10}|&=&3\times4^{10-3}+|S_{10-2}|&=&3\times4^7+|S_8|&=&52\,429 \end{array} The number of Bauman strings of length 1010 in which the first letter is CC and the last letter is DD is 52 429.

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

Source: CEMC, University of Waterloo, licensed CC-BY-NC-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.