Skip to content

Instantly share code, notes, and snippets.

@julijanjug
Last active March 13, 2021 22:31
Show Gist options
  • Save julijanjug/b82564f9c0ccec42b9f20d1633ca59f5 to your computer and use it in GitHub Desktop.
Save julijanjug/b82564f9c0ccec42b9f20d1633ca59f5 to your computer and use it in GitHub Desktop.
Algoritmi turing machine for multiplication
name: multiplication Julijan Jug
source code: |
# Adds 1 to a binary number.
input: '1101110'
blank: 'b'
start state: q0
table:
q0:
1: {write: 'b', R: q1}
0: {write: 'b', R: q13}
q1:
[1]: R
0: {R: q2}
q2:
[1]: {write: 'x', R: q3}
0: {write: 'b', L: q13}
q3:
1: R
0: {R: q4}
q4:
['b']: {write: 1, L: q5}
1: R
q5:
[1]: L
0: {L: q51}
q51:
[1]: {L: q52}
'x': {R: q53}
q53:
0: {write: 'b', L: q13}
q52:
['x']: {R: q6}
[1]: {L: q52}
q6:
1: {write: 'x', R: q7}
0: {R: q7}
q7:
[1,0]: R
'b': {write: 1, L: q8}
q8:
1: L
0: {L: q9}
q9:
1: L
'x': {write: 'x', R: q10}
q10:
1: {write: 'x', R: q6}
0: {write: 0, L: q11}
q11:
'x': {write: 1, L}
0: {L: q12}
q12:
1: L
'b': {R: q0}
q13:
[1]: {write: 'b', R}
['x']: {write: 'b', L}
0: {write: 'b', R: done}
done:
positions:
q0: {x: 37.34, y: 453.16}
q1: {x: 119.65, y: 341.1}
q2: {x: 199.16, y: 204.91}
q3: {x: 278.34, y: 338.42}
q4: {x: 363.05, y: 228.35}
q5: {x: 450.69, y: 321.41}
q51: {x: 456.41, y: 79.52}
q53: {x: 221.42, y: 79.53}
q52: {x: 568.73, y: 80.66}
q6: {x: 569.19, y: 263.32}
q7: {x: 656.26, y: 167.76}
q8: {x: 725.34, y: 272}
q9: {x: 729.13, y: 450.64}
q10: {x: 568.5, y: 453.69}
q11: {x: 387.76, y: 452.4}
q12: {x: 222.33, y: 451.52}
q13: {x: 31.26, y: 147.48}
done: {x: 32.66, y: 33.54}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment