Help with context free grammar excercise
I think you can do it in this way
$$\begin{align}
X&amp;\to A\ |\ aXc\ |\ aAc\\
A&amp;\to aA_t\\
A_t&amp;\to aA_t\ |\ B\\
B&amp;\to bB_t\\
B_t&amp;\to bB_t\ |\ \epsilon\\
\end{align}$$
Here $X$ can choose to do the first transformation, if there are not going to be any $c$s. $X$ can do the second transformation many times to add an initial chunk of the same amount of $a$s and $c$s, or do the third transformation to put a last pair of an $a$ and a $c$.
In that third case, it goes to $A$ which puts one extra $a$ and goes to $A_t$, which can put even more $a$s or go to put $b$s.
Then $B$ puts one $b$ and goes to $B_t$, which puts as many more $b$s as wanted or terminates.
But check it. This is the first ever context free grammar rules that I write in my life.

Shorter rules by nir shahar
$$
\begin{align}
S&amp;\to AB\ |\ aSc\\
A&amp;\to aA\ |\ a\\
B&amp;\to bB\ |\ b
\end{align}
$$