; Mark first bit, then go find the right-hand side of the tape
start 1 b r find_right
start 0 a r find_right
start a a r halt-reject
start b b r halt-reject
start _ _ r halt-reject<br>
; Skip over all bits until we find a blank symbol or marked symbol,
; then move left and switch to the "rightmost" state
find_right 0 0 r find_right
find_right 1 1 r find_right
find_right _ _ l rightmost
find_right a a l rightmost
find_right b b l rightmost<br>
; Mark the rightmost bit, then go find the left-hand side of
; the tape
rightmost 0 a l find_left
rightmost 1 b l find_left
rightmost b b r halt-accept
rightmost a a r halt-reject<br>
; Skip over all bits until we find a blank symbol or marked symbol,
; then move right and switch to the "start" state
find_left 0 0 l find_left
find_left 1 1 l find_left
find_left a a r start
find_left b b r start