%% file ctm03.txt %% cTM binary counting a's and b's %% put initial count 0 left of input string q0 a/a,L q1 q0 b/b,L q1 q0 c/c,L q1 q1 #/0,R q2 %% move to the right end q2 a/a,R q2 q2 b/b,R q2 q2 c/c,R q2 q2 0/0,R q2 q2 1/1,R q2 q2 #/#,L q3 %% erase a, b, or c %% no action on c %% if no a, b or c then halt q3 a/#,L q4 q3 b/#,L q4 q3 c/#,L q3 %% increment count q4 a/a,L q4 q4 b/b,L q4 q4 c/c,L q4 q4 0/1,R q2 q4 1/0,L q4 q4 #/1,R q2