Skip to content

Instantly share code, notes, and snippets.

@fhuszar
Created September 20, 2024 13:17
Show Gist options
  • Save fhuszar/888f378da59d24109af547cc105ab438 to your computer and use it in GitHub Desktop.
Save fhuszar/888f378da59d24109af547cc105ab438 to your computer and use it in GitHub Desktop.
# Sorts 0s and 1s in a sequence.
#to be used at turingmachine.io
input: '0010110100001'
blank: ' '
start state: valid0
table:
# Valid string ending in zero
valid0:
0 : R
1 : {R: valid1}
' ' : {R: done}
valid1:
1: {R}
0 : {write: 1, L: carryback}
' ': {L: done}
carryback:
1: {L}
[0,' '] : {R: placezero}
placezero:
[0, 1] : {write: 0, R: valid0}
done:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment