Guest User

Untitled

a guest
Jan 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. Usage: python twistalltips.py < scrambles_file.txt > new_scrambles_file.txt
  4. """
  5. import random
  6. import sys
  7.  
  8. tips = {"u", "l", "r", "b"}
  9. scrambles = sys.stdin.readlines()
  10. for scramble in scrambles:
  11. scramble_seq = scramble.split()
  12. twisted_tips = {move[0] for move in scramble_seq if move[0] in tips}
  13. additional_tips = tips - twisted_tips
  14. additional_scramble_seq = [tip + ["", "'"][random.randint(0, 1)] for tip in additional_tips]
  15. new_scramble = " ".join(scramble_seq + additional_scramble_seq)
  16. print(new_scramble)
Add Comment
Please, Sign In to add comment