Bob has several pennant flags, each of which is either red, white or blue. To celebrate his national pride in the upcoming Olympics, he wants to string together 9 pennant flags, such that each of the colors is represented at least once, and no two consecutive flags have the same color.
How many different strings of 9 flags can Bob create?
Note : The string is an arrangement of 9 flags from left to right. 2 strings are different if the arrangements of the colors of those 9 flags are different.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Nice...
The number of strings where adjacent flags have different colours = 3 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 768
But out of these string combinations, there are 6 that only contains two colours: RWRWRWRWR, WRWRWRWRW, BRBRBRBRB, RBRBRBRBR, BWBWBWBWB, WBWBWBWBW
Therefore, the number of strings that have different adjacent colours and has three colours represented = 768 - 6 = 762
For the first pennant flag, you have 3 colors you can choice. For the second, only 2 (excluding the color selected before). For the third, 2 (excluding the color selected before). We'll repeat this till the 9 t h pennant flag, so in total we have 3 ⋅ 2 8 = 7 6 8 possible strings. But, remember that the problem states that the strings should have at least one pennant flag of each color. Thus, we need to exclude the following strings:
r e d − w h i t e − r e d − w h i t e − … − w h i t e − r e d
r e d − b l u e − r e d − b l u e − … − b l u e − r e d
w h i t e − r e d − w h i r e − r e d − … − r e d − w h i t e
w h i t e − b l u e − w h i t e − b l u e − … − b l u e − w h i t e
b l u e − r e d − b l u e − r e d − … − r e d − b l u e
b l u e − w h i t e − b l u e − w h i t e − … − w h i t e − b l u e
And finally, the answer is 7 6 8 − 6 = 7 6 2 .
In the third excluded string, i meant " w h i t e ", and not " w h i r e ". Sorry! :D
Let us start arranging the flags from one side.... The first flag we can choose in 3 ways as there are 3 colors..the next flag can be chosen in 2 ways as we are forbidden to put same colored flags side by side....the next one again in 2 ways(In this case the color of the first flag is allowed but the 2nd color in forbidden but the 3rd color is allowed and hence 2 choices)...the next one again in 2 ways.....In this way we can choose the 9 flags in 3 ∗ 2 8 ways... Next we have to subtract the flags that do not use all the 3 colors...in this case we can choose the first flag in 2 ways and all the other places only have one possibility....We can choose the two colors used in 3 ways....So the total number of ways which use less than 3 colors is = 3 ∗ 2 = 6 So the total number of possible colorings = 3 ∗ 2 8 − 6 = 7 6 2 Note:We don't need to to subtract the flags that use 1 color because we have already taken into consideration that the next flag will be of a different color.....
The first flag can be any color, so we have 3 choices for it. However, since the second flag (and every flag after it) can't be the same color as its predecessor, we only have 2 choices for it. This gives us 3 × 2 8 = 7 6 8 different strings. However, this counts the strings which are composed of only two colors (i.e. strings of the form color 1, color 2, color 1, color 2, color 1, color 2, color 1, color 2, color 1). We must remove these from our total. The number of strings with only two colors and no adjacent flags of the same color can be found this way: There are three options for the first color and 2 options for the second. This gives us 3 × 2 = 6 two-color strings. Subtracting 6 from our previous total gives 768-6= 7 6 2
I believe you meant "However, this OVER -counts the strings which are composed of only two colors."
Log in to reply
Well, I was referring to the two-color strings, so what I meant was "this includes the strings which are composed of only two colors". It would seem to me that using the term "over-count" would have implied that the list of two color strings I had was too long. At that point I didn't have such a list or compilation, so I thought it wouldn't have made sense. Thank you for your feedback! I'm quite new to writing solutions for problems, so I'll take all the help I can get!
How about the arrangement is like r w b r w b r w b? Or r w b w r w b w b?
Log in to reply
Why wouldn't those arrangements be included in the way that I explained it? I'm just confused as to why you mentioned those specific strings.
Number of different strings of 9 flags = {3 * (2^8)} - {3 * 2 * (1^7)} = 768 - 6 = 762.
Let
a
n
denote the number of different strings of length
n
according to the above restrictions. Let
b
n
be the number of different strings of length
n
without the restriction that all colors should appear at least once. Then
b
n
=
b
n
−
1
⋅
2
, since any string of length
n
−
1
can be continued in two ways - by adding a color that is different from the last. Clearly,
b
1
=
3
. Solving, we get
b
n
=
3
⋅
2
n
−
1
. Now, to ensure that all colors appear - we need to subtract the sequences in which only two colors appear - select the color that does not appear - 3. Now select the starting color - 2. From here the string is fixed, since the second color is not the first, and so on.
So, for any
n
≥
3
we have
a
n
=
3
⋅
2
n
−
1
−
3
⋅
2
.\
In particular,
a
9
=
3
⋅
2
7
−
6
=
7
6
2
.
Consider constraint that no 2 consecutive flags to be same colour :
lets say colours are A,B C. Starting from right moving towards left, first we can choose any of the 3 colours lets say we chose A, next we can choose B/C.
Likewise we get 3 * 2^(n-1).
But there is another constraint we have to choose all the colours atleast once. In the first calculation we have broken this assumption 6 times.So final answer becomes 3*2^(n-1)-6
First flag can be any of three colors. Once first flag is chosen, every ith flag has just two choices since it can not be (i-1)th color. So the options are 3* 2^8. But this solution counts all those combinations when there are just two colors used. We need to exclude those options. For any given color to be not present in these combinations, there are just two ways since first string can be any of two colors and rest all have to alternate. For all the three colors this makes 2 3 = 6 choices. Answer, thus is 3 2^8 - 2*3 = 762
For the first selected flag, there will be 3 options. For the second there will be 2, because whatever color the first one is, the second one can't be. The third one will also have 2 options, and so on and so forth. Multiplying these all together gives you 768, the answer. Right? Wrong. If you tried 768, you were wrong because they specified that there had to be at least one of each color flag. There are 6 ways to have only 2 colors with no consecutive 2 being the same. So the answer is 7 6 8 − 6 , or 7 6 2 .
Let we put the red, white and blue colors in the vertices of a triangle a let 1 correspond to going from one color to its neighbor in a clockwise direction and 0 - in counterclockwise. Then, any sequence of 9 flags without repetition can be decoded by first color and a sequence of 8 0's and 1's. The only two sequences we have to exclude are 01010101 and 10101010 since they correspond to absence of one of the color. Altogether there are 3*(2^8-2)=762 combinations.
To satisfy the second condition, that no two consecutive flags have the same color, we can do the following:
We have 3 choices for the first flag (red, blue, or white), 2 choices for the 2nd flag (it cannot be the same as the first), 2 choices for the 3rd flag (it cannot be the same as the second), and so on, so our total number of choices is
3 × 2 8
However, we overcounted a bit because some of these do not include a color; for example, one string included is RBRBRBRBR, which does not include white. Overall, there are 3 ⋅ 2 = 6 overcounts: 3 choices for the first color and 2 choices for the second color. (The six overcounts are RBRBRBRBR, BRBRBRBRB, RWRWRWRWR, WRWRWRWRW, BWBWBWBWB, and WBWBWBWBW.)
All the other strings satisfy the given conditions - they contain every color at least once - hence, our final answer is equal to
3 × 2 8 − 6 = 7 6 8 − 6 = 7 6 2 ■
the first position has 3 choice the 8 positions rest have 2 choice so we have 3 × 2 8 combinations. but there are 6 cases where there only 2 colors so the final result is 3 × 2 8 − 6 = 7 6 2
Problem Loading...
Note Loading...
Set Loading...
We use complementary counting, first counting the number of strings of flags such that no consecutive flags are the same color. There are 3 choices for the first flag, and 2 for each other flag, because the only restriction is it cannot be the same color as the previous flag, this is a total of 3 × 2 8 = 7 6 8 .
Now, if not all three colors are represented, then either only two or only one is. If only one is, there must be two consecutive flags of the same color, so we ignore this case. If there are two colors, there are 3 choices for the first flag, 2 for the second, and the remainder of the colors are determined. This means the answer is 3 × 2 8 − 3 × 2 = 7 6 2