Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. tape = list(input())
  2. i = 0
  3. q = 'q0'
  4. q_list = [q]
  5.  
  6. while q != 'q2':
  7. if q == 'q0':
  8. if tape[i] == '0':
  9. tape[i] = '1'
  10. i+=1
  11. q = 'q1'
  12. q_list.append(q)
  13. elif tape[i] == '1':
  14. tape[i] = '0'
  15. i+=1
  16. q= 'q1'
  17. q_list.append(q)
  18. elif tape[i] == " ":
  19. tape [i] = " "
  20. i+=1
  21. q= 'q0'
  22. q_list.append(q)
  23. elif q == 'q1':
  24. if tape[i] == '0':
  25. tape[i] = '1'
  26. i+=1
  27. q = 'q1'
  28. q_list.append(q)
  29. elif tape[i] == '1':
  30. tape[i] = '0'
  31. i+=1
  32. q= 'q1'
  33. q_list.append(q)
  34. elif tape[i] == " ":
  35. tape [i] = " "
  36. i+=1
  37. q= 'q2'
  38. q_list.append(q)
  39. print(''.join(tape))
  40. print(' '.join(q_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement