Skip to content

Instantly share code, notes, and snippets.

name: CSC 404 -- f(n) = n%3
source code: |-
input: '11111111'
blank: ' '
start state: zero
table:
zero:
1: {write: ' ', R: one}
' ': {R: done}
one:
name: CSC 404 -- f(n) = n%3
source code: |-
input: '11111111'
blank: ' '
start state: zero
table:
zero:
1: {write: ' ', R: one}
' ': {R: done}
one:
name: 'CSC 404 - Equal Number of 0s, 1s, and 2s '
source code: |-
#input: '000011112222'
input: '000001111122222'
#input: '00112'
#input: '00122'
#input: '001122012'
blank: ' '
start state: start
name: CSC 404 - Binary ADD (v2) - With CleanUp
source code: |
#Binary Addition!
#Here we assume the inputs are both of length max(n,m) + 1 where n and m are the lengths of the two binary numbers. (The addtional +1 is for a padded 0 at the start of each)
#Example! Add 7 + 11 i.e., 0b111 + 0b1011 since 7 is 3 bits and 11 is 4 bits we place these on the tape as two 5 bit numbers (with added padding of zeros)
input: '00111+01011'
blank: ' '
start state: seekPlus
table:
name: CSC 404 - Binary ADD (v2)
source code: |-
#Binary Addition!
#Here we assume the inputs are both of length max(n,m) + 1 where n and m are the lengths of the two binary numbers. (The addtional +1 is for a padded 0 at the start of each)
#Example! Add 7 + 11 i.e., 0b111 + 0b1011 since 7 is 3 bits and 11 is 4 bits we place these on the tape as two 5 bit numbers (with added padding of zeros)
input: '00111+01011'
blank: ' '
start state: seekPlus
table:
name: CSC 404 - Binary ADD
source code: |-
#Binary Addition!
#Here we assume the inputs are both of length max(n,m) + 1 where n and m are the lengths of the two binary numbers. (The addtional +1 is for a padded 0 at the start of each)
#Example! Add 7 + 11 i.e., 0b111 + 0b1011 since 7 is 3 bits and 11 is 4 bits we place these on the tape as two 5 bit numbers (with added padding of zeros)
input: '00111+01011'
blank: ' '
start state: seekPlus
table:
name: CSC 404 - f(n) = 2n
source code: |
input: '1111'
blank: ' '
start state: seekEnd
table:
seekEnd:
1: {R: seekEnd}
' ': {L: seek1}
seek1:
name: CSC 404 - Unary MIN (v2)
source code: |-
input: '111*11111'
blank: ' '
start state: seek1
table:
seek1:
'1': {write: 'X', R: seekEnd}
'X': {R: seek1}
'*': {write: 'Y', R: leftMin}
name: CSC 404 - Unary MIN
source code: |-
#f(n1,n2) = min(n1,n2)
input: '111*11111'
#input: '11111*111'
blank: ' '
start state: seek1
table:
seek1:
name: CSC 404 - Infinite COPY
source code: |-
input: '1011#'
blank: ' '
start state: seekDigit
table:
seekDigit:
'0': {write: 'X', R: have0}
'1': {write: 'Y', R: have1}
'#': {write: 'Z', R: haveH}