In how many ways can we permute the digits $2,3,4,5,2,3,4,5$ if identical digits must not be adjacent? 
In how many ways can we permute the digits $2,3,4,5,2,3,4,5$ if identical digit must not be adjacent?

I tried this by first taking total permutation  as $\dfrac{8!}{2^4}$
Now $n_1$ as $22$ or $33$ or $44$ or $55$ occurs differently
$N_1 = \left(^7C_1\times \dfrac{7!}{8}\right)$
And $n_2 = \left(^4C_1 \times 4!\right)$
Using the inclusion-exclusion principle I got:
$\dfrac{8!}{16}-\left(^7C_1\times\dfrac{7!}{8}\right)+\left(^4C_1\times4!\right)$
But answer was wrong
Please help me solve the question
This question is from combinatorics and helpful for RMO  

You need a few more inclusion-exclusion steps to complete this approach.
Without constraints, you do indeed have $\dfrac {8!}{2^4} = 2520 $ arrangements.
Then there are $\dfrac {7!}{2^3} = 630$ cases where a $22$ is found in the arrangement, and similarly for the other digits.
Then there are $\dfrac {6!}{2^2} = 180$ cases where both a $22$ and a $33$ are found, and similarly for other pairs, etc.
So by inclusion-exclusion, we have to subtract the paired cases then add back the  double-paired cases, then subtract off triple-paired again and finally add in the cases where all digits appear in pairs.
$$\frac {8!}{2^4} - \binom 41\frac {7!}{2^3} + \binom 42\frac {6!}{2^2} -
\binom 43\frac {5!}{2} + \binom 44\frac {4!}{1} \\[3ex]
=2520 -4\cdot 630 +6\cdot 180-4\cdot60 + 24 = 864$$
[Sharp eyes might notice that $\frac {8!}{2^4} = \binom 41\frac {7!}{2^3}$, shortening the calculation process.]
