Skip to content

Instantly share code, notes, and snippets.

@gimiki
Last active December 1, 2021 17:42
Show Gist options
  • Save gimiki/8218d77dc2fd48cdf71ad702da6a09a9 to your computer and use it in GitHub Desktop.
Save gimiki/8218d77dc2fd48cdf71ad702da6a09a9 to your computer and use it in GitHub Desktop.
Turing machine that calculates the function f(x)=x. View it on https://turingmachine.io/?import-gist=ID with ID that you see in the URL
name: func_ID_01
source code: |
# Macchina di Turing che calcola la funzione f(x)=x
# Alfabeto: {0,1, ' '}
blank: ' '
input: '10110'
start state: q0
table:
q0:
' ': {write: ' ', R: HALT}
0: {write: X, R: q1}
1: {write: Y, R: q2}
q1:
0: {write: 0, R: q1}
1: {write: 1, R: q1}
' ': {write: ' ', R: q3}
q2:
0: {write: 0, R: q2}
1: {write: 1, R: q2}
' ': {write: ' ', R: q4}
q3:
0: {write: 0, R: q3}
1: {write: 1, R: q3}
' ': {write: 0, L: q5}
q4:
0: {write: 0, R: q4}
1: {write: 1, R: q4}
' ': {write: 1, L: q5}
q5:
0: {write: 0, L: q5}
1: {write: 1, L: q5}
' ': {write: ' ', L: q5}
X: {write: 0, R: q0}
Y: {write: 1, R: q0}
HALT:
positions:
q0: {x: 170.77, y: 298.7}
q1: {x: 226.17, y: 178.32}
q2: {x: 272.32, y: 413.64}
q3: {x: 398.14, y: 148.44}
q4: {x: 450.91, y: 371.32}
q5: {x: 458.67, y: 237.28}
HALT: {x: 96.4, y: 421.26}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment