# How many sequences from S do not start with A and end with B?

I'm preparing for exams and came across this question from a past paper. I've answered part a and b, but this part c I need some help to figure out please!

Let S be the set of all sequences of length 5 whose elements are letters of the English alphabet.

How many sequences from S do not start with A and end with B?

• To clarify... "do not start with A and end with B" Do you mean "do not start with A and do start with B" or do you mean "simultaneously do not start with A and do not end with B"? – JMoravitz May 7 '19 at 18:50

Do you want sequences that do not start with A (and end with B)? Or sequences that do not (start with A and end with B)?

In the first case, we can fix B and then note that we have $$26^3 \cdot 25$$ choices for the other letters, because we can choose from all $$26$$ letters for the middle three letters, and from $$25$$ letters (excluding A) for the first. So we have $$26^3 \cdot 25$$ possible sequences.

In the second case, we can count the number of sequences that do start with A and end with B to be $$26^3$$ since we fix the first and last letters and have then $$26$$ choices for each of the remaining three letters. The total number of possible sequences will be $$26^5$$, so the number of sequences that do not start with A and end with B will be $$26^5 - 26^3$$

• The question is a bit confusing itself, it would've been clearer if it said: do not start with A but end with B, or do not start with A, neither end with B. However, you did the best thing by explaining both which was really helpful. Thanks a lot! – T. Mike May 7 '19 at 19:26

Count the total number of such sequences in $$S$$ (I assume letters may repeat, so there are $$26^5$$ different sequences). Then, count how many sequences start with $$A$$ and end with $$B$$. Since you are fixing both $$A$$ and $$B$$, there are there letters left. There are $$26^3$$ different sequences that do start with $$A$$ and end with $$B$$. Next, subtract.

There are

$$26^5-26^3$$

different sequences in $$S$$ that do not start with $$A$$ and end with $$B$$.

• Thanks for clarifying that with a different approach! – T. Mike May 7 '19 at 19:28

In the Interest of Clarity:

This post is on the premise that that the statement "How many sequences from S do not start with A and end with B?" means we seek the number of sequences which...

• ... do not start with $$A$$, and
• ... do end with $$B$$

A similar argument for the alternative interpretation (in which you cannot start with $$A$$ and cannot end with $$B$$) can be made, though.

Also I take a more direct approach in this answer: other answers seem to have gone with the complementary approach (which is totally valid, whichever is easier for you to work with).

Hint for My Interpretation:

So, you know that each sequence has the form

$$x_1 x_2 x_3 x_4 x_5$$

where, without restriction, $$x_i \in \{A,B,C,...,Y,Z\}$$ for all $$i$$. There would be $$26$$ choices for each.

With the given restriction (and interpretation), you would have that $$x_1 \ne A$$ and $$x_5 = B$$.

With this in mind, how many choices are there for $$x_1$$? $$x_2$$? And so on? Since they are independent choices (no choice affects the others), you can multiply the number of possibilities together. That is to say, if you had $$n_k$$ choices for $$x_k$$, then your answer is

$$n_1 \cdot n_2 \cdot n_3 \cdot n_4 \cdot n_5$$

• Why $x_5 = B$ for sure? – 雨が好きな人 May 7 '19 at 18:47
• Because it is a given restriction in the problem: "How many sequences from S do not start with A and end with B?" – Eevee Trainer May 7 '19 at 18:48
• Oh, I see. I think there are two possible interpretations of this: we either want ‘sequences that do not (start with A and end with B)’ or ‘sequences that do not start with A (and end with B)’. – 雨が好きな人 May 7 '19 at 18:49
• Yeah, I see what you mean... I think I'll append a note to the start of my post for clarity and ask the OP. – Eevee Trainer May 7 '19 at 18:50