-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Computability", exercise 2 #8
Comments
2 questions about the above: A] the algorithm should be able to solve all the possible 0-1 sequences? B] do we have to have the algorithm write the result in the starting cell? If we can pick only one sequence at time as an input and we must write the output on the left side of the first input (6 inputs) done: If we can pick only one sequence at time as an input and we must write the output on the first input (5 inputs) end:` p.s. I spent a considerable amount of time trying to set an algorithm for multiple 1-0 sequences of five inputs, at max I was able to cover a couple of possibilities.. if this is the request and someone wants to share with me how to do it, it would be really appreciated :) |
Hi everyone! I was asking myself the same thing you mentioned in A]. I would be very interested in knowing how to build and implement such an algorithm. @essepuntato could you please explain it class or at another more convenient time? input: '11000' Hope that's ok! |
|
I came up with two different solutions (they work with any given input): the first makes the assumption of having a blank cell at the starting position pointed by the head (using an extra blank symbol at the start of the input), the second one only uses 0 and 1 and shifts the cells to the right before running the algorithm.
Second solution:
|
2 different ways: input: ' 10111' Way 2 input: ' 01101' |
This solution is based on the approach that if the first (or the second) value '1' is followed by the value '0' in the next cell, then it couldn't be possible to have three 1's in a row (in a five digits context). That's the reason why it doesn't need to always scan to the rightmost cell to return 0. The output of the first is '0':
While the output of the second is '1':
|
I struggled with this one and decided to check out my classmates' answers;
@mangiafrangette this is genius! Both of them. The idea of the count states really makes things so much easier. I especially find the second solution ingenious, with the separate copy and count states, and the count state being "backwards" (from L to R). It took me a while (trying different inputs) to fully understand its workings, but now I do and love it! |
Note: Initial state: A Issue: Machine does not stop, but continues writing the result in an endless loop.
|
I tried to write a solution to all 5 digit combinations in the most abstract way. I do not use any ingenious techniques to minimize computation time but at least I feel like it would provide Note that I wrote the initial digit combination the machine has read so far after the percentage sign. In this way one can see what the machine has seen so far. input: ..... (5 random digits either 1 or 0) |
input: '00111' B: C: D: y: ' ‘ : {write: 1, L: return} x: |
Hi all, As you already know, there are plenty of possible different solutions to this problem, and you guys have already provide different working approaches here – thanks a lot for this! I'm providing the solution to this exercise I've sketched during the previous lecture so as to be reused in the Turing Machine Visualization tool for testing it. Remember that when one do not specify any "write" instruction implicitly means that the head will write on the tape exactly the same symbol that is already written there.
|
Consider an algorithm that takes as input a 0-1 sequence of exactly five symbols, and returns 1 if such sequence contains at least three consecutive 1s, and returns 0 otherwise. Implement such algorithm with a Turing machine, where the cell correspondent to the starting position of the head is where the final result must be stored, while the following five cells are initialised with the 0-1 sequence of five symbols used as input of the algorithm.
The text was updated successfully, but these errors were encountered: