Skip to content

Instantly share code, notes, and snippets.

@ADCDS
Created December 1, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ADCDS/b5ca7dea4d2f27f33489f59339fa5156 to your computer and use it in GitHub Desktop.
Save ADCDS/b5ca7dea4d2f27f33489f59339fa5156 to your computer and use it in GitHub Desktop.
#Check if a string W is concated with self
#ex of accepted word: abaaba
input: '<abaabaab'
blank: ' '
start state: start
table:
start:
<: {write: <, R: A1}
A1:
' ': {write: ' ', R: accept}
a: {write: a, R: B2}
b: {write: b, R: B2}
X: {write: X, R: F}
B2:
a: {write: A, R: C3}
b: {write: B, R: C3}
C3:
a: {write: a, R: C3}
b: {write: b, R: C3}
X: {write: X, R: C3}
' ': {write: X, L: D4}
D4:
a: {write: a, L: D4}
b: {write: b, L: D4}
X: {write: X, L: D4}
A: {write: a, R: A1}
B: {write: b, R: A1}
F:
X: {write: X, R: F}
' ': {write: ' ', L: G}
G:
X: {write: ' ', L: H}
A: {write: A, L: J}
B: {write: B, L: J}
H:
X: {write: X, L: H}
A: {write: A, L: H}
B: {write: B, L: H}
a: {write: A, R: I}
b: {write: B, R: I}
I:
X: {write: X, R: I}
A: {write: A, R: I}
B: {write: B, R: I}
' ': {write: ' ', L: G}
J:
X: {write: X, L: J}
A: {write: A, L: J}
B: {write: B, L: J}
a: {write: a, L: J}
b: {write: b, L: J}
<: {write: <, R: K}
K:
X: {write: X, R: K}
a: {write: X, R: L}
b: {write: X, R: M}
' ': {write: ' ', L: accept}
L:
a: {write: a, R: L}
b: {write: b, R: L}
A: {write: X, L: J}
X: {write: X, R: L}
M:
a: {write: a, R: M}
b: {write: b, R: M}
B: {write: X, L: J}
X: {write: X, R: M}
accept:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment