Skip to content

Instantly share code, notes, and snippets.

@huzaifaarain
Last active November 20, 2019 19:38
Show Gist options
  • Save huzaifaarain/23f26c073d5816daf61efb2313d5e112 to your computer and use it in GitHub Desktop.
Save huzaifaarain/23f26c073d5816daf61efb2313d5e112 to your computer and use it in GitHub Desktop.
name: Problem 1
source code: |-
input: '00#111#000000'
blank: ' '
start state: s1
table:
s1:
0: {R: s2}
'#': {R: s5}
s2:
0: {R: s2}
'#': {R: s3}
s3:
'#' : {R: s4}
1: {R: s6}
s4:
' ': {R: accept}
s5:
1: {R: s5}
'#': {R: s4}
s6:
1: {R: s6}
'#': {R: s7}
s7:
0: {R: s8}
s8:
0: {R: s8}
' ': {L: s9}
s9:
[0,1,'#']: L
' ': {R: each0}
each0:
0: {write: ' ', R: each1}
[1,'#']: {R: scan}
each1:
0: R
'#': R
1: {write: B, R: markC}
C: {L: next0}
markC:
[1,C,'#']: R
0: {write: C, L: next1}
next1:
[1,C,'#']: L
B: {R: each1}
next0:
[0,'#']: L
B: {write: 1, L}
' ': {R: each0}
scan:
[1,C,'#']: R
' ': {R: accept}
accept:
positions:
s1: {x: 22.71, y: 20}
s2: {x: 21.21, y: 228.46}
s3: {x: 273.54, y: 191.46}
s4: {x: 304.43, y: 67.4}
s5: {x: 166.16, y: 52.04}
s6: {x: 40.59, y: 307.07}
s7: {x: 200.01, y: 324.89}
s8: {x: 283, y: 274.59}
s9: {x: 272.74, y: 389.36}
each0: {x: 432.38, y: 335.11, fixed: false}
each1: {x: 557.82, y: 420.85, fixed: false}
markC: {x: 701.28, y: 406.09, fixed: false}
next1: {x: 617.28, y: 297.56}
next0: {x: 432.45, y: 480, fixed: false}
scan: {x: 477.08, y: 178.34, fixed: false}
accept: {x: 393.18, y: 35.6}
name: Problem 2
source code: |-
input: '00#11#11'
blank: ' '
start state: start
table:
start:
0: {write: c, R: goforward}
'#': { R: base_case }
base_case:
1: {R: blank}
goforward:
0: {R: goforward}
'#': {R: fone}
fone:
[0,'#'] : {R: reject}
1: {R: ones}
ones:
1: { write: x, R: even}
[0,'#'] : {R: reject}
x: {R: ones}
' ': {R: reject}
even:
[0,'#'] : {R: reject}
1: { R: ones }
x: {R: even}
' ': {L: goback}
goback:
[1,x,'#',0]: L
c : { R: markC }
markC:
0: {write: c, R: goforward}
[1,x,'#']: L
c: {R: verifyLeft}
verifyLeft:
c: { R: verifyLeft }
'#': { R: verifyLeft }
1: {R: verifyRight}
verifyRight:
x: { R: verifyRight }
' ': {R: accept}
blank:
[0,1,'#']: {R: reject}
' ': {R: accept}
x: {R: accept}
reject:
accept:
positions:
start: {x: 46.11, y: 25.37}
base_case: {x: 252.15, y: 35.43}
goforward: {x: 75.57, y: 264.34}
fone: {x: 216.2, y: 207.84}
ones: {x: 351.96, y: 197.13}
even: {x: 603.06, y: 191.5}
goback: {x: 575.02, y: 376.4}
markC: {x: 79.93, y: 456.01}
verifyLeft: {x: 704.2, y: 452.23}
verifyRight: {x: 706.7, y: 257.97}
blank: {x: 461.93, y: 32.54}
reject: {x: 356.44, y: 359.17}
accept: {x: 706.53, y: 41.09}
name: Problem 3
source code: |-
input: '000111111'
blank: ' '
start state: init
table:
init:
[1,X,C] : {R: init}
0: {write: X, L: moveToStart}
' ': {L: verifyString}
moveToStart:
[1,0,X] : {L: moveToStart}
[' ',C]: {R: markFC}
markFC:
' ': {L: markSC}
1: {write: C, R: markSC}
[0,C,X]: {R: markFC}
markSC:
1: {write: C, L: goback}
[0,X,C]: {R: markSC}
verifyString:
[C,X]: {L: verifyString}
' ': {R: accept}
goback:
[1,0,X,C]: {L: goback}
[' ']: {R: init}
accept:
positions:
init: {x: 177.41, y: 311.54}
moveToStart: {x: 354.84, y: 96.56}
markFC: {x: 600.77, y: 113.33}
markSC: {x: 729.45, y: 359.4}
verifyString: {x: 59.2, y: 112.54}
goback: {x: 426.65, y: 372.76}
accept: {x: 41.23, y: 253.01}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment