Last active
August 29, 2015 14:07
-
-
Save onjin/73d101a39fae710ca4cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import random | |
import fileinput | |
def shakeit(word): | |
if len(word) < 3: | |
return word | |
middle = list(word[1:-1]) | |
random.shuffle(middle) | |
return word[0] + ''.join(middle) + word[-1] | |
for line in fileinput.input(): | |
print ' '.join((shakeit(word) for word in line.strip().split(' '))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
echo 'shake this'| ./shakeit.py
./shakeit.py < file.txt
./shakeit.py file1.txt file2.txt file3.txt