- Kate is planning for her $8$ days Study Period.
- Each day she can choose one of the $3$ Subjects: Math, English or Physics.
- She never studies Math and English on consecutive days. (i.e.No ME or EM)
- She also wants to study at least all $3$ subjects on at least one day of her study period.
How many different schedules are possible?.
I tried $3^4-3 \cdot 2^4+3 \cdot 1= 36$ for $4$ day schedule. I draw the picture and there shall be only $10$ possible schedules. Not sure how to do exclusion on no math and English on consecutive days. Please help. Thank you.
The following answer is a two step approach based upon the Goulden-Jackson Cluster Method and PIE, the principle of inclusion-exclusion.
Fist step: $A(z)$ avoiding bad words
We consider the set of words of length $n\geq 0$ built from an alphabet $$\mathcal{V}=\{E,M,P\}$$ and the set $B=\{EM, ME\}$ of bad words, which are not allowed to be part of the words we are looking for. We derive a generating function $A(z)$ with the coefficient of $z^n$ being the number of wanted words of length $n$.
According to the paper (p.7) the generating function $A(z)$ is \begin{align*} A(z)=\frac{1}{1-dz-\text{weight}(\mathcal{C})}\tag{1} \end{align*} with $d=|\mathcal{V}|=3$, the size of the alphabet and $\mathcal{C}$ being the weight-numerator of bad words with \begin{align*} \text{weight}(\mathcal{C})=\text{weight}(\mathcal{C}[EM])+\text{weight}(\mathcal{C}[ME]) \end{align*}
We also keep track of the used letters which are needed when considering PIE and calculate according to the paper \begin{align*} \text{weight}(\mathcal{C}[EM])&=-(EM)z^2-Ez\cdot\text{weight}(\mathcal{C}[EM])\\\ \text{weight}(\mathcal{C}[ME])&=-(ME)z^2-Mz\cdot\text{weight}(\mathcal{C}[ME])\\ \end{align*} which results in \begin{align*} \text{weight}(\mathcal{C}[EM])=-EMz^2\frac{1-Ez}{1-EMz^2}\tag{2}\\ \text{weight}(\mathcal{C}[ME])=-EMz^2\frac{1-Mz}{1-EMz^2}\\ \end{align*}
From (1) and (2) in (1) we obtain the generating function
Note that \begin{align*} A(z)&=A(z;1,1,1)\\ &=\frac{1-z^2}{1-3z+z^2+z^3}\\ &=1+3z+7z^2+17z^3+41z^4+99z^5\\ &\qquad+239z^6+577z^7+\color{blue}{1\,393}z^8+3\,363z^9+8\,119z^{10}+\cdots \end{align*} where the coefficients of $z^n$ give the number of words of length $n$ which do not contain $EM$ or $ME$. These coefficients (calculated with Wolfram Alpha) are in accordance with the numbers stated in @GregBrowns answer.
Second step: With PIE to $B(z;E,M,P)$
We are looking for words which contain each of the letters $\{E,M,P\}$ and denote the corresponding generating function $B(z;E,M,P)$. We do so by excluding words which do not contain one of these letters using PIE. To get words which do not contain for instance $E$, we calculate \begin{align*} [E^0]A(z;E,M,P)=A(z;E,M,P)|_{E=0} \end{align*} which we denote as $A(z;0,M,P)$.
Using PIE we calculate $B(z;E,M,P)$ with the help of (3) as \begin{align*} B&(z;E,M,P)\\ &=A(z;E,M,P)\\ &\qquad-A(z;0,M,P)-A(z;E,0,P)-A(z;E,M,0)\\ &\qquad+A(z;0,0,P)+A(z;0,M,0)+A(z;E,0,0)\\ &\qquad-A(z;0,0,0)\\ &=\frac{1-EMz^2}{1-(E+M+P)z+EMz^2+EMPz^3}\\ &\qquad-\frac{1}{1-(M+P)z}-\frac{1}{1-(E+P)z}-\frac{1-EMz^2}{1-(E+M)z+EMz^2}\\ &\qquad+\frac{1}{1-Pz} +\frac{1}{1-Mz}+\frac{1}{1-Ez}\\ &\qquad-1\tag{4}\\ \end{align*}
Result: There are $\color{blue}{882}$ valid words of length $8$ which do not contain $EM$ and $ME$ and so, that each word contains the three letters $E,M,P$.
Two plausibility checks: $n=4$ and $n=8$.
We see in (5) there are $10$ valid words of length $4$. These are \begin{align*} &\text{EEPM}\quad\text{EPMM}\quad\text{EPMP}\quad\text{EPPM}\quad\text{MMPE}\\ &\text{MPEE}\quad\text{MPEP}\quad\text{MPPE}\quad\text{PEPM}\quad\text{PMPE} \end{align*}
We manually calculate the coefficient of $z^8$ from (5). We use the coefficient of operator $[z^n]$ to denote the coefficient of a series. We obtain \begin{align*} \color{blue}{[z^8]}&\color{blue}{B(z)}=[z^8]\left(\frac{1+z}{1-2z-z^2 }-\frac{2}{1-2z}+\frac{1}{1-z}\right)\\ &=\left([z^8]+[z^7]\right)\sum_{j=0}^\infty z^j(2+z)^j-2[z^8]\sum_{j=0}^\infty(2z)^j+[z^8]\sum_{j=0}^\infty z^j\\ &=\sum_{j=0}^8[z^{8-j}](2+z)^j+\sum_{j=0}^7[z^{7-j}](2+z)^j-2(2^8)+1\\ &=\sum_{j=0}^8\binom{j}{8-j}2^{2j-8}+\sum_{j=0}^7\binom{j}{7-j}2^{2j-7}-2^9+1\\ &=\binom{4}{4}2^0+\binom{5}{3}2^2+\binom{6}{2}2^4+\binom{7}{1}2^6+\binom{8}{0}2^8\\ &\qquad+\binom{4}{3}2^1+\binom{5}{2}2^3+\binom{6}{1}2^5+\binom{7}{0}2^7-511\\ &=1+40+240+448+256\\ &\qquad+8+80+192+128-511\\ &\,\,\color{blue}{=882} \end{align*} as expected.