# Turing machine problem

#### munalisa

Design a Turing machine that does the following: when given a string of m ones and n ones separated
by a single blank square as input, output a blank tape if (m + n) is even and a single 1 if (m + n) is odd.
Describe this Turing machine by a machine table. Note: Insert a blank in a given space in the table if (i)
the machine will halt in that state while scanning that symbol, or (ii) it is impossible for the machine to
be in that state while scanning that symbol.

#### phillip1882

Code:
Table |    1   |     _|
-> A1 |  _A2 R |  _A3  R
A2 |  _A1 R |  _A4 R
A3 |  _A4 R |  1 Halt
A4 | _A3 R  |  _ Halt

#### munalisa

Code:
Table |    1   |     _|
-> A1 |  _A2 R |  _A3  R
A2 |  _A1 R |  _A4 R
A3 |  _A4 R |  1 Halt
A4 | _A3 R  |  _ Halt
thanks for your reply philip but I still don' t get it. how is the input string supposed to look like? which numbers sould i put in the string? also what do you mean by
''Table | 1 | _| '' ? how are the m ones and n ones separated ?

#### phillip1882

okay, so A1 though A4 are states. 1 and _ are potential inputs to the machine, _ meaning a blank state.
the machine solves the problem in four steps.. first it rotates through A1 and A2, A1 meaning odd and A2 meaning even. it replaces every 1 with a blank.
once it reaches blank it goes into either state A3 or A4 depending on if it finished odd or even, up to the blank. from here, it replaces each 1 with the blank, shifting between odd and even states until it gets to the end, a blank state. if it finishes odd, replace with 1 otherwise leave blank.

#### phillip1882

as a couple brief evamples.
1111_11_ would result in _ _ _ _ _ _ _ _
and
111 _ 111111_ would result in _ _ _ _ _ _ _ _ _ _ 1