Skip to content

Instantly share code, notes, and snippets.

@pmas98
Last active April 23, 2025 03:19
Show Gist options
  • Save pmas98/ff5fdcb9d719e262e1394ba808b806ba to your computer and use it in GitHub Desktop.
Save pmas98/ff5fdcb9d719e262e1394ba808b806ba to your computer and use it in GitHub Desktop.
input: '101#101'
blank: ' '
start state: start
table:
start:
X: R
Y: R
0: {write: X, R: find_match_0}
1: {write: Y, R: find_match_1}
'#': {R: verify_second_part}
' ': {R: accept}
find_match_0:
[0,1,X,Y]: R
'#': {R: find_0}
find_match_1:
[0,1,X,Y]: R
'#': {R: find_1}
find_0:
X: R
Y: R
0: {write: X, L: go_back}
1: {R: reject}
' ': {R: reject}
find_1:
X: R
Y: R
1: {write: Y, L: go_back}
0: {R: reject}
' ': {R: reject}
go_back:
[0,1,X,Y]: L
'#': {L: back_to_start}
back_to_start:
[0,1,X,Y]: L
' ': {R: start}
verify_second_part:
X: R
Y: R
0: {R: reject}
1: {R: reject}
' ': {R: accept}
accept:
[0,1,X,Y,'#',' ']: {R: accept}
reject:
[0,1,X,Y,'#',' ']: {R: reject}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment