Describing the pattern in which iterations make two, cyclic sets equal $A = \{a,b,c,d,e\}$
$B = \{a,b,c\}$
$C = \{0,1,2,3,4,5,6\}$
The first few iterations are as follows:
$1.$ $a,a,0$
$2.$ $b,b,1$
$3.$ $c,c,2$
$4.$ $d,a,4$
$5.$ $e,b,5$
$...$
I'm trying to figure out at which iterations we will have $x,y,z$ such that $x=y$ and $z=5$. I wrote a program to "solve" this problem for me, and I discovered that this happens at iterations $32,46,60,137,151,165...$. The problem for me is that I don't see how to derive this pattern. In particular, the following are true:
$32.$ $c,c,5$
$...$
$46.$ $b,b,5$
$...$
$60.$ $a,a,5$
$...$
 A: Firstly, I think your program is incorrect as the $32$nd iteration is $(b,b,3)$ and the first iteration of $(x,y,z)$ with $x=y$ and $z=5$ is $(c,c,5)$ at iteration 48. 
In any case, the iterations you desire will occur when $n$ is a solution to the system \begin{align*}
n &\equiv 1,2\text{ or }3\pmod{15}\\
n&\equiv 6\pmod 7
\end{align*}
The first equation comes from the iterations $(x,y,z)$ with $x=y$, and the second takes into account the iterations with $z=5$. 
A: The least common multiple of the sizes 3,5 of sets $A,B$ is 15, so that $x=y$ will occur at any position $15k+1,15k+2,15k+5.$ For each of these, set it equal to $5$ mod 7 and solve. 
EDIT: They should be set to 6 mod 7 since you start at step 1 with a 0 in column 3.
Thanks to @Casteels for pointing out this offset in a comment.
$15k+1=6$ mod 7 has solution $k=7r+5$, and $15k+2=6$ mod 7 has solution $k=7r+4$, finally $15k+3=6$ mod 7 has solution $k=7r+3.$ So the three solution families are
$$15(7r+5)+1=105r+76,\\ 15(7r+4)+2=105r+62, \\ 15(7r+3)+3=105r+48.$$
