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$.

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$
