finding overlapping permutations I have a data set $3\; 4\; 5\; 6\; 7\; 8\; 9$
I want to find all the permutations that can be formed using this such that neither $7$ nor $8$ is adjacent to $9$.
 A: Try breaking this up into two cases- when 9 is on the end and when 9 isn't on the end. Consider the different possible positions for the 9 in each case. Then consider the different possibilities for the number(s) adjacent to 9. Then finally, the possibilities for the remaining numbers.
A: Hint: First find total no. of permutations.
Then consider 7,8,9 as one no. and so total 5 nos. to permute.
Now as we can have 7,8,9 and 9,8,7 so it is two permutations which are non-permissible.
But other permuatations are valid .so find such non-permissible permutations.
Subtract thr two to get an answe.
Thanks
A: We count the complement, the bad permutations where $7$ or $8$ is adjacent to $9$. 
How many permutations have $7$ adjacent to $9$? There are $6$ places for the pair to go, and they can be in either order, giving a total of $(6)(2)$ ways to place $7$ and $9$. The rest can be placed in $5!$ ways, for a total of $(6)(2)(5!)$.
Similarly, there are $(6)(2)(5!)$ bad permutations with $8$ adjacent to $9$.
If we add, we have double-counted the permutations where $7$ and $8$ are both adjacent to $9$. to count these, note that the $9$ can be put in $5$ places. For each of these, there are $2$ ways to place the $7$ and $8$, and $4!$ ways to place the rest. So the number of bad permutations is
$$(6)(2)(5!)+(6)(2)(5!)-(5)(2)(4!).$$
A: Use the principle of inclusion-exclusion.
There are $7!$ permutations in total.
Among these are $6!$ with $7$ immediately followed by $9$ (count by joining $7$ and $9$ to a single new object), similarly $6!$ each with $9,7$, with $8,9$, and with $9,8$ in sequence.
Thus we get $7!-4\cdot 6!$.
However, we deducted the $5!$ permutations with $7,9,8$ and the $5!$ permutations with $9,8,7$ twice. Hence the final count is
$$ 7!-4\cdot 6!+2\cdot 5!.$$
A: In each permutation $7$ either sits in the corners or inbetween other digits.
We will first place $7$ then other digits.
We will count the number of unfavourable cases.
case 1: $7$ sits inbetween other digits.
No. of places where $7$ can be placed is $5$.As we are counting the unfavouable cases so either $8$ or $9$ is beside $7$ or both of them.
subcase 1a: $8$ is placed on one side of $7$ but $9$ not placed in the other side.
For $8$ we have two choices(namely the left and right place of $7$).For 9 we have $4$ choices(namely all the vacant places except the one empty neighbourhood of $7$).F0r $3,4, 5,6$ we have $4,3,2,1$ choices respectively so we have $5\times2\times4\times 4!$ numbers in this subcase.
subcase 1b: $9$ is placed on one side of $7$ but $8$ not placed in the other side.
Similarly we have $5\times2\times4\times 4!$ numbers in this subcase.
subcase 1c: $8,9$ are placed on two sides of $7$
Number of choices for $8$ is $2$,after placing $8$ there is only one place for $9$.for others we have $5!$ ways of arranging then so the no. of cases in this category is $5\times 2\times 5!$
case 2: $7$ is placed on one corner
subcase 2a:$8$ sits on the side of $7$
Number of places for $7$ is 2. Number of places for $8$ is 1.Others can be placed in $5!$ ways ,so total no. of cases=$2\times 5!$
subcase 2b:$9$ sits on the side of $7$
Similar arguements as above shows the number of cases to be $2\times 5!$ 
So the total no. of unfavouable cases equal $5\times2\times4\times 4!+5\times2\times4\times 4!+5\times 2\times 5!+2\times 5!+2\times 5!=x$
So the total no. of favourable cases=$7!-x$
