Skip to content

Instantly share code, notes, and snippets.

@d4wae89d498
Last active June 20, 2025 15:38
Show Gist options
  • Save d4wae89d498/21d451159f2c300a3103826c30a87025 to your computer and use it in GitHub Desktop.
Save d4wae89d498/21d451159f2c300a3103826c30a87025 to your computer and use it in GitHub Desktop.
turing exam
name: binary increment
source code: |+
input: 'abba'
blank: ' '
start state: q0
table:
ERROR_TOO_MANY_B:
ERROR_NOT_ENOUGH_A:
ERROR_A_B_COUNT:
ERROR_NB_A_PAS_PAIR:
HALT:
CNB0:
'b': {write: ' ', L: ERROR_TOO_MANY_B}
'a': {write: 'a', L: CNB0}
' ': {write: ' ', R: HALT}
CNB1:
'b': {write: 'b', L: CNB0}
'a': {write: 'a', L: CNB1}
' ': {write: ' ', L: ERROR_A_B_COUNT}
CNB2:
'b': {write: 'b', L: CNB1}
'a': {write: 'a', L: CNB2}
' ': {write: ' ', L: ERROR_A_B_COUNT}
CNB3:
'b': {write: 'b', L: CNB2}
'a': {write: 'a', L: CNB3}
' ': {write: ' ', L: ERROR_A_B_COUNT}
q0:
'a': {write: 'a', R: q1}
'b': {write: 'b', R: q0}
q1:
'a': {write: 'a', R: q2}
'b': {write: 'b', R: q1}
' ': {write: ' ', L: ERROR_NOT_ENOUGH_A}
q2:
'a': {write: 'a', R: q3}
'b': {write: 'b', R: q2}
' ': {write: ' ',L: CNB2}
q3:
'a': {write: 'a', R: q4}
'b': {write: 'b', R: q3}
' ': {write: ' ',L: ERROR_NB_A_PAS_PAIR}
q4:
# ...
positions:
ERROR_TOO_MANY_B: {x: 640.28, y: 68, fixed: false}
ERROR_NOT_ENOUGH_A: {x: 242.1, y: 112.34, fixed: false}
ERROR_A_B_COUNT: {x: 549.81, y: 462.18, fixed: false}
ERROR_NB_A_PAS_PAIR: {x: 241.53, y: 403.46, fixed: false}
HALT: {x: 551.53, y: 138.04, fixed: false}
CNB0: {x: 677.44, y: 208.37, fixed: false}
CNB1: {x: 607.35, y: 332.55, fixed: false}
CNB2: {x: 463.58, y: 347.58, fixed: false}
CNB3: {x: 408.96, y: 480, fixed: false}
q0: {x: 273.82, y: 20, fixed: false}
q1: {x: 386.87, y: 103.31, fixed: false}
q2: {x: 359.29, y: 246.47, fixed: false}
q3: {x: 214.93, y: 261.43, fixed: false}
q4: {x: 109.4, y: 355.96, fixed: false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment