Combinatorics and bijective function exercise One group of $8$ friends are going to the theatre, and have tickets to sit in $8$ consecutive places. Between them, $J$ is mad at $M$ and $P$. In how many different forms can they sit, in a way that $J$ doesn't sit next to $M$ nor to $P$?
Research effort:
This is the same as having a bijective function, so the total number of combinations is $8!$
Then I got to substract the cases in whitch J and M are sitting next to each other, this is:
$ABCDFPH$ whith $H = JM$
Number of combinations: $7!.2!$
same as the cases with $J$ and $P$
$ABCDFMH$ whith $H = JP$
Number of combinations: $7!.2!$
But now I have substracted twice the cases in which they sit: $MJP$ and $PJM$.
$ABCDFH$ whith $H = MJP$ ($J$ fixed)
This cases are $6!.2!$
Then the total number of posibbilities is: $8!-2.7!.2!+6!.2!$
Is this fine or I'm sending poor $J$ next to his horrible enemies?
 A: Nicely done!
As an alternative approach, you could note that the main issue is where $J,M,P$ are sitting. So, we could proceed casewise as follows:
(1) If we seat $J$ on an end--$2$ ways to do this--then that leaves $6$ open seats in which we can put $M,P$--$\binom{6}{2}\cdot2!=\frac{6!}{4!}$ ways to do this--at which point, once those three are seated, there are $5!$ ways to seat the rest. All told, this situation can occur in $$2\cdot\frac{6!}{4!}\cdot5!=6!\cdot 10$$ ways.
(2) If we seat $J$ in a non-end seat--$6$ ways to do this, then there are only $5$ open sets in which we can put $M,P$--$\binom{5}{2}\cdot2!=\frac{5!}{3!}$ ways to do this--and then $5!$ ways to seat the rest, as before. This situation can occur in $$6\cdot\frac{5!}{3!}\cdot5!=6!\cdot20$$ ways.
So, in total (since there's no other way to place them), we can seat them in $6!\cdot30$ ways, which is the same as $8!-2\cdot7!2!+6!2!$.

Yet another alternative. Note that there are $5!$ ways to order the neutral friends, $2!$ ways to order the problematic (from $J$'s perspective) friends, and only one way to order $J$. So, we can also obtain the answer by counting the number of ways to arrange a $J,$ two $P$s (for problematic friends) and $5$ $N$s (for non-problematic friends in a row so that $J$ is not seated next to any $P$s, then multiplying that answer by $5!2!$ (to bring in the distinctions that we hid behind $P$ and $N$.
(1) If we seat $J$ on an end--$2$ ways to do this--then we need to fill the spot next to $J$ with a $N.$ Once we place the two $P$s in $2$ of the $6$ remaining spots--$\binom{6}{2}=15$ ways to do this, then the remaining spots will be filled be the remaining $N$s. So, there are $30$ ways to do this.
(2) If we seat $J$ in a non-end seat--$6$ ways to do this--then the two spots next to $J$ must be filled by $N$s. Placing the $P$s in $2$ of the $5$ remaining spots--$\binom{5}{2}=10$ ways to do this--then the remaining spots will be filled by $N$s. So, there are $60$ ways to do this.
Thus, there are $90$ ways to arrange $J$ and our $P$s and $N$s, so $5!2!\cdot90$ ways to arrange our $8$ moviegoers, which is once again the same answer.
