# A NPDA for the language $L = \{w \mid w \in \{a,b,c\}^*, n_c(w) = n_a(w) + n_b(w)\}$

Consider the language $L = \{w, w \in \{a,b,c\}^*, n_c(w) = n_a(w) + n_b(w)\}$, where $n_q(\omega)$ is defined to be "the number of $p \in \omega$.

I have tried a couple of PDA's that follow this whole idea of a stack-replacement kind of algorithm, but the reasoning behind it is incorrect. I know it is not the right structure; furthermore, those examples of my previous attempts don't really fit in the context of the question that I'm asking.

There I have a gut feeling that I need to exploit the fact that $0=n_a(w)+n_b(w)-n_c(w)$ but I have absolutely the faintest idea how to do so. When building this kind of "counting machine," what are some design patterns that I can exploit?

You don't need the "N" in your "NPDA", you can do this with a deterministic counter machine. Every time you see an $a$ or a $b$ increment the counter by $1$, every time you see a $c$ decrement the counter by $1$. When you get to the end of the string, if the counter is at $0$ then accept, else reject.