- #1
Miike012
- 1,009
- 0
I boxed the portion of the solution that I am questioning.
How come the number of invalid strings is only 3n-1 - an-1 and not
3(3n-1 - an-1) ?
As you can see there are three cases (Which are to the right of the black box)
In all the three cases, the portion boxed in red is a string of length n-1 and does not have any consecutive numbers
Case 1:
The first number is a 1, then the second number must also be a 1
so that the string has a pair of consecutive numbers
Case 2
The first number is a 2, then the second number must also be a 2
so that the string has a pair of consecutive numbers
Case 3
The first number is a 0, then the second number must also be a 0
so that the string has a pair of consecutive numbers
How come the number of invalid strings is only 3n-1 - an-1 and not
3(3n-1 - an-1) ?
As you can see there are three cases (Which are to the right of the black box)
In all the three cases, the portion boxed in red is a string of length n-1 and does not have any consecutive numbers
Case 1:
The first number is a 1, then the second number must also be a 1
so that the string has a pair of consecutive numbers
Case 2
The first number is a 2, then the second number must also be a 2
so that the string has a pair of consecutive numbers
Case 3
The first number is a 0, then the second number must also be a 0
so that the string has a pair of consecutive numbers