I have been given the problem of writing a turing machine with the commands:
if, while, whileNot, read X, write X, goLeft, goRight, HALT
The problem was simply "calculate a two's complement number, from number with \$ on the left and # on the right, ex: $10110100#"
I started by writing this pseudocode to flip the bits:
whileNot read # if read 1 write 0 if read 0 write 1 goRight
But then I realized once 'write 0' executes, 'if read 0' will immediately be true and undo my work. I need a statement that is effectively 'else if read 0', is there any turing trickery that I can employ to do something like this?