Skip to content

Instantly share code, notes, and snippets.

@onjin
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onjin/73d101a39fae710ca4cc to your computer and use it in GitHub Desktop.
Save onjin/73d101a39fae710ca4cc to your computer and use it in GitHub Desktop.
#!/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(' ')))
@onjin
Copy link
Author

onjin commented Oct 7, 2014

echo 'shake this'| ./shakeit.py
./shakeit.py < file.txt
./shakeit.py file1.txt file2.txt file3.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment