# Single tape Turing Machine that accepts string with at least five G's and at most three T's?

I am looking to create a single tape acceptor Turing machine acting upon the language of any ASCII string, that would only accept strings that contains at least five G's and at most three T's, and rejects any other ASCII string input. I am kind of stuck on how the machine would know that it had encountered greater than or equal to five G's and less than or equal to three T's.

• What about some states that remember how many Gs ad Ts you have read? :) Jan 19 '21 at 10:34

Here, you would have 24 "counting" states, labelled by $$(g, t)$$ for $$0 \leq g \leq 5$$ and $$0 \leq t \leq 3$$. Whenever you read some $$G$$ while already in state $$(g, t)$$, you move on to the corresponding state $$(g+1, t)$$ (and if you read a $$T$$, you go to $$(g, t+1)$$). Otherwise, you simply loop on your current state.
Now, you have to enforce your conditions: if you read a $$T$$ while in a state $$(g, 3)$$, you reject the word, and if your word end while you are in a state $$(g, t)$$ with $$g < 5$$, you reject too.