Skip to content

Instantly share code, notes, and snippets.

@tzdanows
Created May 9, 2021 23:56
Show Gist options
  • Save tzdanows/7d87ba33be19cbeb9967b9d5d106a13f to your computer and use it in GitHub Desktop.
Save tzdanows/7d87ba33be19cbeb9967b9d5d106a13f to your computer and use it in GitHub Desktop.
TM2 from turingmachines.io
input: '000001#000011'
blank: ' '
# Problem TM2.
start state: start
table:
start:
0: {write: ' ', R: have0}
1: {write: ' ', R: have1}
# Base case: empty string.
' ': {R: reject}
have0:
[0,1]: R
'#': {R: match0}
have1:
[0,1]: R
'#': {R: match1}
match0:
x: R
0: {write: x, L: back}
1: {R: accept}
match1:
x: R
1: {write: x, L: back}
0: {R: reject}
back:
[0,1,'#',x]: L
' ': {R: start}
accept:
reject:
### Inputs tried: ###
# '01011#01001' REJECTED
# '011#111' ACCEPTED
# ' ' REJECTED
# '000001#000011' ACCEPTED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment