Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Ok guys, today s goal is to build a Turing machine simulator. For those that don t know what it is, see the Wikipedia article. The state table we are using today is found at the end of the Formal Definition that s part of that page.
The code will take a sequence of "0" and "1" string characters, an integer representing the character that the machine starts with, and an integer representing the state of the program (in no particular order), and output the final result of the operations on the string, as well as the final position. Examples:
Example 1:
1010 state A(0)
^ (3)
1011 state B(1)
^ (2)
1011 state B(1)
^ (1)
1111 state A(0)
^ (2)
1111 state C(0)
^ (3)
1111 HALT
^ (2)
Example 2:
110100 state B(1)
^ (3)
110100 state B(1)
^ (2)
111100 state A(0)
^ (3)
111100 state C(2)
^ (4)
111110 state B(1)
^ (5)
1111110 state A(0)
^ (6, tape has been extended to right)
1111111 state B(1)
^ (5)
1111111 state B(1)
^ (4)
1111111 state B(1)
^ (3)
1111111 state B(1)
^ (2)
1111111 state B(1)
^ (1)
1111111 state B(1)
^ (0)
01111111 state B(1)
^ (0, tape has been extended to left)
11111111 state A(0)
^ (1)
11111111 state C(2)
^ (2)
11111111 HALT
^ (1)
Misc:
- Your code must properly handle attempts to write into "blank spaces" on the tape, by extending the string as necessary.
- Since the state machine specified does not specify any sort of "blank tape" action, treat all blank values as 0.
- You must count only the method that handles evaluation of a string with initial state, how you output that data is up to you.
- Moving right on the tape is incrementing up (string position 0 is all the way at the left), state 0 is A, state 1 is B, and state 2 is C.
(hopefully) final edit: I offer my most sincere apologies as to the confusion and trouble I ve caused with this question: I misread the supplied state table I listed, and got it backwards. I hope you ll forgive me for wasting your time; it was entirely unintentional!