Created
April 20, 2019 14:29
-
-
Save SED4906/74075683e2926e4d0bd968344752f3eb to your computer and use it in GitHub Desktop.
turingmachine.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds two binary numbers. | |
input: '0111 1100' | |
blank: ' ' | |
start state: end | |
table: | |
# scan to the right | |
end: | |
[1,0]: R | |
' ' : {R: right} | |
# scan to the rightmost digit | |
right: | |
[1,0]: R | |
' ' : {L: borrow} | |
# then borrow the 1 | |
borrow: | |
1 : {write: 0, L: left} | |
0 : {write: 1, L} | |
' ' : {write: ' ', L: done} | |
# scan to the left | |
left: | |
[1,0] : L | |
' ' : {L: carry} | |
# then carry the 1 | |
carry: | |
1 : {write: 0, L} | |
0 : {write: 1, R: end} | |
' ' : {R: end} | |
done: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment