Skip to content

Instantly share code, notes, and snippets.

@willshiao
Last active January 22, 2020 00:30
Show Gist options
  • Save willshiao/73e21f8b62e204dc11d284d67a7abbd9 to your computer and use it in GitHub Desktop.
Save willshiao/73e21f8b62e204dc11d284d67a7abbd9 to your computer and use it in GitHub Desktop.
Turing Machine for L_bin
name: copy 1s
source code: |
# input: 'aaaaaaaaaaaaaaaaaaaaaaaaab11001'
input: 'aaaaaab10'
blank: ' '
start state: q_0
table:
q_0:
a: {R: s_b, write: x}
s_b:
a: {R: s_b}
b: {R: x_r}
c:
0: {R: c}
' ': {R: accept}
x_r:
1: {R: v_r}
v_r:
[0,1]: {R: v_r}
' ': {L: s_l}
s_l:
0: {L: s_l, write: 1}
1: {L: x_l, write: 0}
x_l:
[a,b,1,0]: {L: x_l}
x: {R: q_1}
q_1:
a: {R: s_b_1, write: x}
b: {R: c}
s_b_1:
a: {R: s_b_1}
b: {R: v_r}
accept:
positions:
q_0: {x: 384.76, y: 38.7, fixed: false}
s_b: {x: 517.9, y: 91.55, fixed: false}
c: {x: 177.2, y: 311.6, fixed: false}
x_r: {x: 518.41, y: 240.97, fixed: false}
v_r: {x: 518.66, y: 396.06, fixed: false}
s_l: {x: 588.83, y: 274.96, fixed: false}
x_l: {x: 434.75, y: 268.61, fixed: false}
q_1: {x: 314.17, y: 348.96, fixed: false}
s_b_1: {x: 393.8, y: 468.28, fixed: false}
accept: {x: 202.97, y: 170.9, fixed: false}
editor contents: |
input: 'aaaaaaaaaaaaaaaaaaaaaaaaab11001'
# input: 'aaaaaab10' #fails
blank: ' '
start state: q_0
table:
q_0:
a: {R: s_b, write: x}
s_b:
a: {R: s_b}
b: {R: x_r}
c:
0: {R: c}
' ': {R: accept}
x_r:
1: {R: v_r}
v_r:
[0,1]: {R: v_r}
' ': {L: s_l}
s_l:
0: {L: s_l, write: 1}
1: {L: x_l, write: 0}
x_l:
[a,b,1,0]: {L: x_l}
x: {R: q_1}
q_1:
a: {R: s_b_1, write: x}
b: {R: c}
s_b_1:
a: {R: s_b_1}
b: {R: v_r}
accept:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment