Created
December 23, 2018 19:16
-
-
Save sdfsdhgjkbmnmxc/122bebfe35c4b4a3ea6cce28b8730d48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import sys | |
import re | |
def mix_word(s): | |
if len(s) < 3: | |
return s | |
middle = list(s[1:-1]) | |
random.shuffle(middle) | |
return s[0] + ''.join(middle) + s[-1] | |
def mix_text(s): | |
return re.compile('\w+', re.UNICODE).sub(lambda m: mix_word(m.group(0)), s) | |
if __name__ == '__main__': | |
sys.stdout.write(mix_text(sys.stdin.read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment