If $Y_n$ is a sequence of independent random variables with $P(Y_n=0)=2/3,P(Y_n=1)=1/6,P(Y_n=2)=1/6$ and $X_n$ with $X_0=0$ is defined as
$$X_{n+1}= \left\{ \begin{array}{lr} X_n-Y_n & : &X_n=3\\ X_n-1+Y_n &: &1\leq X_n\leq2\\ Y_n & : &X_n=0 \end{array} \right.$$
I don't understand this markov chain. What is its state space and what is the transition matrix? Also: how do I find its invariant distribution when I have the transition matrix?
The state space is $\{0,1,2,3\}$. When at state $0$, the next state has the distribution $\mathcal{Y}$ which is the distribution of $Y_n$. When at state $1$, the next state also has the distribution $\mathcal{Y}$, while at state $2$, it has the distribution $\mathcal{Y}+1$. Finally, at state $3$, it has distribution $3-\mathcal{Y}$. All in all, we obtain the following transition matrix (depending on your convention, this might be the transpose of the transition matrix): $$ \begin{pmatrix} 2/3 & 2/3 & ? & ? \\ 1/6 & 1/6 & ? & ? \\ 1/6 & 1/6 & ? & ? \\ 0 & 0 & ? & ? \end{pmatrix} $$ I'll let you figure out the other half of the matrix. Given the transition matrix, the invariant distribution is an eigenvector corresponding to the eigenvalue $1$ (and is additionally a distribution). Sometimes the invariant distribution is not unique, though in this case it is.