Skip to content

Instantly share code, notes, and snippets.

@jarodl
Created April 6, 2012 22:09
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/2323431 to your computer and use it in GitHub Desktop.
Save jarodl/2323431 to your computer and use it in GitHub Desktop.
def read_input(input_filename="input.txt"):
with open(input_filename) as f:
return (line.rstrip().split(' ') for line in f.readlines())
def scramble_word(word):
if len(word) > 3:
from random import shuffle
middle = list(word[1:-1])
shuffle(middle)
new_word = word[0] + str.join('', middle) + word[-1]
return new_word
else:
return word
def main():
lines = read_input()
for words in lines:
scrambled = [scramble_word(word) for word in words]
print str.join(' ', scrambled)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment