Use the Inclusion-Exclusion Principle to determine how many ternary strings of length five contain two consecutive $1$s.(explain your answer)
My attempt was to get the string that has all ones. Since the length is five and the ternary contains $0,1,2$ only. This is what I did: $3 \cdot 3 \cdot 3 \cdot 3 \cdot 3$ (each location has $3$ possibilities ) - $2 \cdot 2 \cdot 2 \cdot 2 \cdot 2$ (without $1$s) we get $3^5-2^5= 211$. However, this is not the Inclusion-Exclusion method and I don't know how to apply it to this issue!
Let $A_1$ be the set of ternary strings which contain consecutive 1s at positions $i$ and $i+1$, for $i = 1,\ldots,4$. What you seek is $|A_1\cup\ldots\cup A_4|$. It is easy to compute the size of the intersection of any subfamily of $A_i$s: just raise 3 to the power $j$, where $j$ is the number of places not necessarily filled with 1s. To simplify the formula, let us denote $|A_x\cap A_y\cap A_z\cap\ldots|$ by $a_{xyz\ldots}$.
By the I-E principle, we have $$|A_1\cup\ldots\cup A_4| = (a_1+a_2+a_3+a_4)-(a_{12}+a_{23}+a_{34}+a_{13}+a_{24}+a_{14})+(a_{123}+a_{234}+a_{124}+a_{134})-a_{1234} = 4\cdot 3^3-(3\cdot 3^2+3\cdot 3^1)+(2\cdot 3^1+2\cdot 3^0)-3^0 = 79$$