Skip to content

Instantly share code, notes, and snippets.

@wrouesnel
Last active April 10, 2019 02:46
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 wrouesnel/121f021c81de44bd774d24930b6c2807 to your computer and use it in GitHub Desktop.
Save wrouesnel/121f021c81de44bd774d24930b6c2807 to your computer and use it in GitHub Desktop.
Just a little Python function which scrambles words like that first and last letter are all you need meme.
from random import SystemRandom
rand = SystemRandom()
def scrambler(txt):
"""Disprover for that meme about letter ordering in English."""
words = txt.split(" ")
result_words = []
for word in words:
shuffled = [c for c in word[1:-1]]
rand.shuffle(shuffled)
result_word = word[0] + "".join(shuffled) + word[-1]
result_words.append(result_word)
return " ".join(result_words)
print(scrambler("""This meme isn't true and the examples given always use a relatively simple
sentence with simple composition. There's just not much mix up in short words,
whereas once you start extending it to longer words or more complicated structures things get unintelligble fast."""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment