Let x be the number of weeks; therefore, the two linear equations are

Where T stands for the punches on the tea punch card and C for the punches on the coffee punch card.
Solving by substitution. Set T=C, then

Thus, substitute the value of x=3 into the first equation,

Thus, after 3 weeks, Josiah will have the same number of punches on each card, and he will have 23 punches on each card.
They both can have two cookies and then split the fith one in half