By Jevgenijs Kirmanis NOTE: The behavior of this TM is slightly different than is usually expected because the output doesn't start at the left most cell, but rather is located starting with the first non-empty Notation: 1'=k, 2'=l, 3'=m, 4'=n, 5'=o, 6'=p, 7'=q, 8'=r, 9'=s (NOT TO BE USED FOR INPUT) Phase 1 Delete starting 0s. If no other digits, restore one 0 and accept. Otherwise, 'put a dot' on first digit (to memorize beginning). Move to the end of the decimal number, replace blank with #. Phase 2 [New 1 or 0]. If we are done converting, move on to phase 4. If last digit of decimal number is even, the new last digit of inverted binary number is 0. Otherwise, it is 1. Move to the left of # (end of decimal number). Move on to phase 3 Phase 3 [Divide original by 2] Move to the beginning of decimal number. If first digit is 1 or 1', delete it, otherwise divide by 2 (round down) If the digit is even, next digit will be divided by 2 as above, otherwise 5 will be added to the above result. Repeat until reach # (end of dec. number). Go back to Phase 2 Phase 4 [Reverse the backwards written binary number] Move # from beginning to the end of the number. Then, starting from the end, replace 0 and 1s with xs, writing them in the right order to the right of # Once finished, replace xs and # with blanks, and we are done. CODE: _________________________________________________________________________________ |Phase 1| 1,0,1,_,> 1,_,18,0,> 1,1,2,k,> 1,2,2,l,> 1,3,2,m,> 1,4,2,n,> 1,5,2,o,> 1,6,2,p,> 1,7,2,q,> 1,8,2,r,> 1,9,2,s,> 18,_,H,< 2,0,2,> 2,1,2,> 2,2,2,> 2,3,2,> 2,4,2,> 2,5,2,> 2,6,2,> 2,7,2,> 2,8,2,> 2,9,2,> 2,_,3,#,< |Phase 2| 3,0,4,> 3,2,4,> 3,4,4,> 3,6,4,> 3,8,4,> 3,l,4,> 3,n,4,> 3,p,4,> 3,r,4,> 3,1,5,> 3,3,5,> 3,5,5,> 3,7,5,> 3,9,5,> 3,k,5,> 3,m,5,> 3,o,5,> 3,q,5,> 3,s,5,> 3,_,19,> 4,#,4,> 4,0,4,> 4,1,4,> 4,_,6,0,< 5,#,5,> 5,0,5,> 5,1,5,> 5,_,6,1,< 6,0,6,< 6,1,6,< 6,#,7,< |Phase 3| 7,0,7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