Why this probability of this problem does not equal to this logical answer? Problem Description:
Sophia has 7 days to study 4 subjects (x, y, z, p).. Every day she studies one of them.
Obviously, the possible combinations for her schedule are $4^7$, as she can place any subject in any day.
Question:
How many possible schedule permutations exist where Sophia can study every subject at least once?

My way was the following:
So, I should place at least 4 different subjects in these 7 days. So the probability falls to:
$$P(7, 4)$$
Combining the 3 remaining days we have, where we can place any subject we want, the final probability is:
$$P(7, 4) * 4^3$$
But the books tells me (with a note below the example like it knew I would do it that way) this is wrong. But why? What is the final result then and why?
 A: To see the problem more immediately, try a simpler example: Sophia has 2 days to study 1 subject $(x)$. There is only one way to do this: Study $x$ on both days.
But according to your logic, there are two ways, since we can place $1$ subject $x$ in either of $2$ days, then fill in the remaining day with $x$ as well. The problem is that these two descriptions describe the same plan.
Considering simple examples is always a good idea!
A: If the order of the days matters:
One approach is the inclusion-exclusion principle. We can take the total number of permutations minus those that exclude a subject. Let $A$ represent the event where subject $x$ is excluded, $B$ represent the exclusion of $y$, etc. Then:
\begin{align}
&|A\cup B\cup C\cup D|\\
&=|A|+|B|+|C|+|D|\\
&-(|A\cap B|+|A\cap C|+|A\cap D|+|B\cap C|+|B\cap D|+|C\cap D|)\\
&+(|A\cap B\cap C|+|A\cap B\cap D|+|A\cap C\cap D|+|B\cap C\cap D|) \\
&-|A\cap B\cap C\cap D|\\
\end{align}
Applying values, we get:
$$4 \cdot (3^7) - 6 \cdot (2^7) + 4 \cdot (1^7) - 0 = 7984$$
Now we take the total number of schedules $4^7$ and subtract the invalid cases to get the final answer:
$$W = 4^7 - 7984 = 8400$$
If the order of the days does not matter:
We can immediately cut off $4$ days which will have one subject each.
This reduces the problem to counting subject combinations over $3$ days, which can be treated like a stars-and-bars problem: Imagine that each of the $4$ subjects is a frequency bin and we can allocate $3$ days among them in total. Therefore the total number of ways to study each subject at least once is:
$$W = \binom{3+4-1}{4-1} = 20$$
Those combinations are:
ppppxyz
pppxxyz
pppxyyz
pppxyzz
ppxxxyz
ppxxyyz
ppxxyzz
ppxyyyz
ppxyyzz
ppxyzzz
pxxxxyz
pxxxyyz
pxxxyzz
pxxyyyz
pxxyyzz
pxxyzzz
pxyyyyz
pxyyyzz
pxyyzzz
pxyzzzz

A: Suppose we restrict ourselves to three days and two subjects, $a,b$.
By your method there are three ways to select days to put $a$, then for each two ways to put $b$, then again for each of theses, two ways to select either $a$ or $b$ for the remaining day.   Counting ${}^3\mathrm P_2\cdot 2 ~=~ 3\cdot 2\cdot 2 ~=~ 12$ distinct arrangements.
$$\left\{\begin{array}{c}\rm a\_\,\_ \\\rm  \_a\_ \\\rm  \_\,\_a \end{array}\right\}~\to~\left\{\begin{array}{c}\rm ab\_ &\rm a\_b \\\rm ba\_ & \rm \_ab \\ \rm b\_a & \rm \_ba\end{array}\right\}~\to~ \left\{ \begin{array}{c}\rm aba & \rm aab & \rm abb & \rm abb \\ \rm baa & \rm aab & \rm bab & \rm bab \\ \rm baa & \rm aba & \rm bba & \rm bba\end{array}\right\}$$
Wait... those are not all distinct at all.
We have overcounted some arrangements.   There are only 6 distinct patterns here.

Let us instead count all the ways to arrange two subjects in three days, and then subtract ways to arrange one subject in three days.
$$2^3-2\cdot 1^3 ~=~ 6$$
Extending this back to four subjects and seven days, we need to also apply the principle of inclusion and exclusion.

 $$4^7 - \binom 4 1\cdot 3^7 + \binom 42\cdot 2^7-\binom 43\cdot 1^7+ \binom 44\cdot 0^7 ~=~ 840$$

