I have in my pocket :
- 5 candies ( they are not distinguishable )
- a chocolate cake
- a tooth cake
I want to know how many possibilities I have to place every one in a row without the 2 cakes being next to each other.
I solve it doing $7! -$ number of possibilities they next to each other. (got the the solution by first counting the total number of orderings and then subtracting the ones where the cakes are next to each other)
But I wanted to know if there was another way doing it without solving number of possibilities in which they are next to each other.
Since the candies are indistinguishable, your initial approach is incorrect.
Method 1: We correct your approach.
The total number of arrangements of five indistinguishable candies, one chocolate cake, and one tooth cake is $$\binom{7}{5}2! = \frac{7!}{5!2!} \cdot 2! = \frac{7!}{5!}$$ since we must choose five of the seven positions for the candies, then arrange the chocolate cake and tooth cake in the remaining two positions. The factor of $5!$ in the denominator represents the number of ways the candies could be permuted among themselves without creating an arrangement distinguishable from the given arrangement.
If we line up the five candies in a row, we create six spaces for the cakes, as shown below. $$\square c \square c \square c \square c \square c \square$$ If the two cakes are next to each other, then they must both be in one of these six spaces. Once we choose the space, there are $2!$ ways of arranging the cakes in that space. Hence, there are $6 \cdot 2!$ prohibited arrangements.
Thus, the number of arrangements of five indistinguishable candies, one piece of chocolate cake, and one tooth cake in which the two cakes are not next to each other is $$\binom{7}{5}2! - \binom{6}{1}2! = 21 \cdot 2 - 6 \cdot 2 = 30$$
Method 2: We modify the above approach to directly count those arrangements in which the two cakes are not adjacent.
Line up the five candies in a row as above, creating six spaces in which to place the two cakes. To ensure that the two cakes are not adjacent, we must place the two cakes in separate spaces. There are six ways to place the chocolate cake, which leaves five ways to place the tooth cake. Hence, there are $$6 \cdot 5 = 30$$ ways to arrange five indistinguishable candies, one piece of chocolate cake, and one tooth cake so that the two cakes are not next to each other.