≥ 2 letters) present in the original word ( VIBGYOR ). How many good arrangements are there?
Let us call an arrangement of the letters of the word VIBGYOR good if it doesn't contain any string of letters (lengthDetails and Assumptions
For example, OYVIBRG is not acceptable as it contains the string VIB .
But, IVGBROY is acceptable.
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.
An approach using breadth first search to generate the search space, counting the number of strings with length 7.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
Any letter in the combination must not be followed by its next letter in VIBGYOR. After that just apply inclusion and exclusion principle
Why D7 (Seventh derangement number)? Could you elaborate? For example, OYVIBRG is counted in D7, but it is not acceptable.
Log in to reply
I don't get it. SO there are six possible strings of length 2 right? If I have VI,IB,BG,GY,YO and OR and I have 6 possible ways to place them such that they are consecutive and 5! ways to move the remaining letters then I have 4320 possible 'Bad' arrangements out of 5040. WHy isn't that right?
Log in to reply
If I understand correctly, you have arranged the six strings. That itself is wrong as every letter is occurring twice except V and R.
One may use inclusion-exclusion to prove a generalization-
The number of permutations π of 1 , 2 , . . , n such that π ( j + 1 ) = π ( j ) + 1 for j = 1 , 2 . . , n − 1 is D n + D n − 1 where D n is the n -th Derangement number.
So, here the answer is D 6 + D 5 which equals 2 1 1 9
Problem Loading...
Note Loading...
Set Loading...
Since the characters are all distinct, let's use the string 1 2 3 4 5 6 7 instead. Let G n denote the set of good arrangements for a string of distinct characters of length n . For every string in G n , we can form a string in G n + 1 by adding in a new character n + 1 anywhere that isn't directly after the character denoted by n , giving n good arrangements in G n + 1 for every arrangement in G n (for example, in 2 1 4 3 6 5 we can add a 7 anywhere except after 6 ).
However, consider an arrangement of n characters in which there exist only two characters in order. We could place the n + 1 t h character in between these two to create a good arrangement out of a non-good one. For 1 ≤ k ≤ n − 1 , we can model the triplet k , n + 1 , k + 1 as one character, so we reduce n + 1 characters to n − 1 characters (for example, 6 5 1 2 4 3 can be made into 6 5 1 7 2 4 3 , and 1 7 2 can go anywhere except before 3 ). This allows us to only consider arrangements in G n − 1 , and create n − 1 good arrangements from each one.
Then, ∣ G n + 1 ∣ = ( n ) ∣ G n ∣ + ( n − 1 ) ∣ G n − 1 ∣ . ∣ G 2 ∣ and ∣ G 3 ∣ are easily calculable as 1 and 3 , so:
∣ G 4 ∣ = ( 3 ) ( 3 ) + ( 2 ) ( 1 ) = 1 1
∣ G 5 ∣ = ( 4 ) ( 1 1 ) + ( 3 ) ( 3 ) = 5 3
∣ G 6 ∣ = ( 5 ) ( 5 3 ) + ( 4 ) ( 1 1 ) = 3 0 9
∣ G 7 ∣ = ( 6 ) ( 3 0 9 ) + ( 5 ) ( 5 3 ) = 2 1 1 9