# Turing machine - compare two words

I have a simple turing machine with single tape. I need to compare two words <w1>$<w2>$ and write output. Language is all letters and numbers.

I did comparation with the {a,b} language but there are more characters.

Is only solution do it one by one in different branches? I mean read / mark the letter (enter the letter branch), go to the second word and read /mark the same letter, go to the first word, repeat? My problem with this solution is, when I want to change something I need to remake all branches. The other problems are the error handling, when I do not find the right letter I don't want crash. How handle that?

• Programming Turing machines sucks. – Yuval Filmus Apr 25 at 12:45