q0 B 0 L q1 blank input write 0 q1 B B R q2 blank input stop in q2 q0 1 1 L q3 prepend # q3 B # R q5 prepend # to input CORRECT q4 to q5 following an earlier mistake, a state q4 is no longer used. q5 1 x R q6 q6 1 y R q5 ... q5 #(11)^2k B becomes ...#(xy)^2k q5 B ... q5 #(11)^2k 1 B becomes ...#(xy)^2k q6 B q5 B B L q7 ... (11)^2k, even, prepend 0 q6 B B L q8 ... (11)^2k 1, odd, prepend 1 q7 x x L q7 q7 y y L q7 q7 0 0 L q7 q7 1 1 L q7 q7 # # L q7 q7 B 0 R q10 q8 x B L q9 Like q7, but first erase the extra x q9 x x L q9 q9 y y L q9 q9 0 0 L q9 q9 1 1 L q9 q9 # # L q9 q9 B 1 R q10 q10 0 0 R q10 q10 1 1 R q10 q10 # # R q11 ...#(xy)^k B should become ...#1^k B Convert the ys to 1s q11 1 1 R q11 q11 x x R q11 erase the xs later q11 y x L q12 This looks odd. We convert the leftmost y to x then move left and convert the leftmost x to 1. q12 x x L q12 q12 1 1 R q13 q12 # # R q13 q13 x 1 R q11 q13 # B L q18 q18 0 0 L q18 q18 1 1 L q18 q18 B B R q19 q11 B B L q14 q14 x B L q14 q14 1 1 L q15 q15 1 1 L q15 q15 # # R q5 q14 # B L q14 q14 B B L q16 q16 0 0 L q16 q16 1 1 L q16 q16 B B R q17