Define a grammar from the alphabet $\{ a, b \}$ which accepts the string $w$ where $\#_{w(b)} \leq \#_{w(a)} \leq 2 \#_{w(b)}$

45 Views Asked by At

Given the following problem:

Define a grammar that only generates all the strings from the language of the alphabet $\sum = \{ a, b \}$ such that the number of letters a is more than or equal to the number of letters b and less than or equal to double the number of letters b.

I am not sure how to proceed with these types of problems where I required to maintain a count and a limit of the number of each character in the string.

How do go about resolving such a problem?