I need an algorithm for a turing machine that reads a string from 0 and then writes to tape how many were in binary format.
I understand that in practice, the machine will not actually count 0, but I'm pretty dumb about how to do this.
First of all, I want to mark the place where the binary number starts with X or something else, and then just write 1 for the first 0 and for each of the next 0, if the least significant bit is 0 it becomes 1, but what if it is 1 ? Maybe turn it into 0 and keep going, leaving all 1s to 0s until you find 0 or empty to turn into 1? Again, in this case, it is one and the same, regardless of LSB, because I will do the same, only 0 will be the first position ...
Hmm ... rubber duck ...
source
share