Skip to content

Instantly share code, notes, and snippets.

@jarodl
Created April 28, 2009 05:06
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 jarodl/102954 to your computer and use it in GitHub Desktop.
Save jarodl/102954 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
def scramble(word):
"""Returns word with innards scrambled"""
if len(word) < 4:
return word
innards = list(word[1:-1])
random.shuffle(innards)
return word[0] + ''.join(innards) + word[-1]
def _main():
while 1:
line = sys.stdin.readline()
if not line:
break
sys.stdout.write(' '.join([scramble(w) for w in line.split()]) + '\n')
return 0
if __name__ == "__main__":
sys.exit(_main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment