I am facing difficulty in solving the 18th Question from the above passage.
Attempt:
I have attempted it using principal of inclusion and exclusion.
Let n be the required number of ways.
$n = \text{Total number of ways - Number of ways in which Os and Is are together}$
$\implies n = \dfrac{12!}{3!2!2!} - \dfrac{11!}{2!3!} - \dfrac{10!}{2!2!}+ \dfrac{9!2!}{2!} = 399 \times 8!$
This gives $N = 399$ which is wrong. Can you please tell me why am I getting the wrong answer?

Your mistake is not noticing that the I's can be non-separated two different ways: We can have all three of them together as III, but we can also have II in one place and I in another.
One way to calculate how many ways this can happen is to think of one pair II as a single letter, and the third I as a separate letter, and count the number of words we can make. This will count each III case twice: Once as I II, and once as II I. So we have to subtract the number of such cases once.
With this correction, the final calculation becomes $$ \overbrace{\frac{12!}{3!2!2!}}^{\text{All words}} - \overbrace{\frac{11!}{3!2!}}^{\text{O's not separate}} - \overbrace{\left(\underbrace{\frac{11!}{2!2!}}_{\text{II and I}} - \underbrace{\frac{10!}{2!2!}}_{\text{III}}\right)}^{\text{I's not separate}} + \overbrace{\left(\underbrace{\frac{10!}{2!}}_{\text{OO, II and I}} - \underbrace{\frac{9!}{2!}}_{\text{OO and III}}\right)}^{\text{Neither O's nor I's separate}} $$ which turns out to be $8!\cdot 228$.