An alphabet with two letters and has two rules for creating words:
Any must be part of a string containing an even number of 's.
Any must be part of a string of containing an odd number of 's.
For example, two six-letter words could be and but would not be valid.
How many valid letter words ending in are there?
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.
W ( n , A ) represents the number of n letter words ending with A , W ( n , B ) likewise. W ( n ) = ( X , Y ) where X = W ( n , A ) , Y = W ( n , B )
Some small words: W ( 1 ) = ( 0 , 1 ) because the only valid word is B .
W ( 2 ) = ( 1 , 0 ) because the only valid word is A A
W ( 3 ) = ( 1 , 2 ). Valid words are B A A , A A B , B B B .
One recursive formula: W ( n , A ) = W ( ( n − 2 ) , A ) + W ( n − 2 ) , B ) because you can add A A to the end of any word to make a new word ending in an even number of A .
Another recursive formula: W ( n , B ) = W ( ( n − 2 ) , B ) + W ( n − 1 ) , A ) because you can add B B to the end of a word already ending with an odd number of B or you can add a single B to a word ending with A .
Now we can just make a table to solve
Incidentally, the A + B column is this sequence so an alternate way of solving is to take a ( 2 0 ) − a ( 1 8 ) = 1 8 7 4 − 8 3 9 = 1 0 3 5