Given the following problem:
Design a finite automata that only recognizes the strings of the language $L$ of the alphabet $\sum = \{ a, b \}$ such that each string does not contain any prefixes where the difference between the number of letters $a$ and letters $b$ is more than three.
I am having difficulties conceptualizing this and I was thinking of trying to create a grammar in hopes that it would help but no luck.
How do I put this into concept?
You can easily construct an automaton that counts the number of $a$'s minus the number of $b$'s, as long as that number stays between $-4$ and $+4$.
If that difference stays between $-3$ and $+3$ until the end of the string, then the string is accepted.
If that difference ever gets to either $-4$ or $+4$, then the string is immediately rejected.