I'm trying to design a Turing machine of the following specification:
Let Σ = {a, b}. Given a non-broken string composed of $a$'s and $b$'s, convert every contiguous string of two or more $b$’s to $a$’s, changing nothing else. Concretely, the string ‘$abbbbababb$’ is changed into ‘$aaaaaabaaa$.' The machine halts at the first blank square.
I can use a maximum of five states. Currently the two-or-more bit is throwing me off; when I try to flow-diagram the machine it gets quite complicated. Some guidance would be appreciated.
I don't know the syntaxes used for turing machines, but the following should do it: $$\begin{array}{cc|lc} \text{State}&\text{Character}&\text{Action}&\text{Move}\\\hline 0 & a & \text{none} & \rightarrow\\ 0 & b & \text{State} = 1 & \rightarrow\\ 1 & a & \text{State} = 0 & \rightarrow\\ 1 & b & \text{State} = 2 & \rightarrow\\ 2 & a & \text{State} = 3 & \leftarrow\\ 2 & b & \text{none} & \rightarrow\\ 3 & a & \text{State} = 1 & \rightarrow\\ 3 & b & \text{Character} = a & \leftarrow \end{array}$$
States $0,1,2$ count the number of $b$s seen since the last $a$, topping off at $2$. State $3$ says it has reached the end of $b$s and it is time to go backwards, replacing each $b$ with $a$. When it runs into a character that is already $a$, it resets and starts going forward again.