You can stlil raed seabrmlcd wdors…kindof

Most of you have heard of this effect from an email that went around beginning with: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy…. If you didn’t, go read it now!

So being bored one day (even though I still had piles of homework to get done), I decided to write a python program to scramble my own words and sentences! Grab the file here: WordRearranger.py. I’ll post what I have right now (to fill up some space. Otherwise, this post doesn’t seem all that important!):

"""
Word Rearranger by Michael Huynh

Rearranges the letters inside words for the idea that wrods can siltl
be rbedalae if the fonrt and lsat lteters are kpet cnotsnat.

Version 1 (09/28/04)
Version 2 (09/29/04) - Fixed bug when punctuation counted as part of a word.
  For instance: [However,] would be arranged with the H and the , in fixed
  positions rather than the H, r, and , in fixed positions. Added a recursive
  solution. Thanks to Penguin for pointing out this bug!

Future considerations: Want to modify this program? How about adding a
degree of obfuscation to the program? This value can be adjusted to change
the *extent* to which letters can be moved around. For instance, the word:
[composition] can be extremely jumbled like: [cotiioosmpn], or it can be
mildly jumbled like: [copmsotioin]. This would be an interesting study to
determine the degree of word jumbling that can occur but still retain elements
of recognition.
"""

import random
import re, string

"--------------------------------------"
"Definitions: "

#Function to rearrange letters in a word
def shuffleWord(inWord):

    #Filter for 1, 2, or 3 characters
    if (len(inWord)<4):
        return inWord

    charList = list(inWord)

    #place list into new sequence
    firstChar = charList[0:1]
    lastChar = charList[len(charList)-1:]
    midCharList = charList[1:len(charList)-1]

    #-----------------------------
    #If first and last characters aren't letters or numbers, then
    #scramble where the letters start
    if(re.match('W', lastChar[0])): #If the last character is not a word
        #send first+mid Chars into this function again for processing
        firstAndMiddleChars = midCharList
        firstAndMiddleChars.insert(0, firstChar[0])
        return (shuffleWord(firstAndMiddleChars)+lastChar[0]) # + means concat
    if(re.match('W', firstChar[0])):
        midAndLastChars = midCharList
        midCharList.append(lastChar[0])
        return (firstChar[0]+shuffleWord(midAndLastChars))
    #-----------------------------

    random.shuffle(midCharList) #randomizes the middle characters
    #print firstChar, midCharList, lastChar

    #join together in one list
    wholeShuffledWord = midCharList
    wholeShuffledWord.insert(0, firstChar[0])
    wholeShuffledWord.append(lastChar[0])
    #print wholeShuffledWord

    #convert list into string and return
    shuffledWord = ''.join(wholeShuffledWord)
    #print shuffledWord
    return shuffledWord

"--------------------------------------"
"Main program: "

"!!!! For reading from a file !!!!"
"""
# Open a file, read the text
inputFileHandler = open('sometext.txt', 'r')

#Read into string
inputFile = inputFileHandler.read()
"""
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

"!!!! For manual input !!!!!"
inputFile = "Python is an easy to learn, powerful programming language. It has
efficient high-level data ,structures and a simple but effective approach to
object-oriented programming. Python's elegant syntax and dynamic typing,
together with its interpreted nature, make it an ideal language for scripting
and rapid application development in many areas on most platforms."
"!!!!!!!!!!!!!!!!!!!!!!!!!!!"

#Split string into and word list
listWords = inputFile.split()

#Scramble word
for eachWord in listWords:
    #Split word by characters
    print shuffleWord(eachWord), #comma supresses newline

""" Sample output:
Photyn is an esay to learn, puoerfwl pnmigrramog luganage. It has eiefifnct
hilgheve-l data ,sctuuetrrs and a spmile but efeivftce apoprcah to
ooerjtenb-eitcd pmoaingrrmg. Ph'tyons elgnaet synatx and damniyc tnyipg,
ttehoger wtih its ietnretrped nraute, make it an iaedl lggnuaae for sncirtpig
and riapd appioitclan dvlepnmeeot in many areas on msot plmtorafs.
"""

My conclusions about this letter scrambling idea were very similar to the ones I found on a Cambridge University’s site explaining why this works. I also found a paper that related somewhat to this idea: Reading quickly in the periphery — the roles of lettersand sentences.

Now back to work for me!

5 Comments

  1. Penguin says:

    Just in case you didn’t notice, the paragraph you posted about Python that was “scrambled” (Pthoyn is an easy to lnare… mnay araes on msot pmofrsatl.) is mis-scrambled. The last letters are not always kept constant, so in some words (for example, ‘learn’ and ‘platforms’ in the two fragments I just mentioned) are harder to figure out.

    Just wanted to let you know. <><3

    btw, when are you EVER gonna finish the story about your visit?!

    Posted 9/27/2004 at 6:41 pm | Permalink
  2. Whoa! You’re right! Wow, I didn’t notice that! I should fix this error soon before anyone else sees it….

    Posted 9/27/2004 at 8:34 pm | Permalink
  3. Updated source code to fix problem. Thank you again Pen.

    Posted 9/29/2004 at 10:14 pm | Permalink
  4. Eugene says:

    Hey, my eugene.mikexstudios.com site is finally googleable!

    Posted 9/30/2004 at 5:35 pm | Permalink
  5. i can raed tsehe lertets and it is fnuny the way you can mapunilate wrods.
    tanhykou for sahrning. gdoboye.

    p.s. i remain anonymous

    Posted 11/10/2006 at 8:39 pm | Permalink

One Trackback

  1. [...] mikeXstudios (mikexstudios) wrote,@ 2004-09-27 18:37:00      Current mood:busy You can stlil raed seabrmlcd wdors…kindof Most of you have heard of this effect from an email that went around beginning with: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy…. If you didn’t, go read it now!So being bored one day (even though I still had piles of homework to get done), I decided to write a python program to scramble my own words and sentences! Grab the file here: WordRearranger.py. I’ll post what I have right now (to fill up some space. Otherwise, this post doesn’t seem all that important!): “”" Word Rearranger by Michael Huynh Rearranges the letters inside words for the idea that wrods can siltl be rbedalae if the fonrt and lsat lteters are kpet cnotsnat. Version 1 (09/28/04) Version 2 (09/29/04) - Fixed bug when punctuation counted as part of a word. For instance: [However,] would be arranged with the H and the , in fixed positions rather than the H, r, and , in fixed positions. Added a recursive solution. Thanks to Penguin for pointing out this bug! Future considerations: Want to modify this program? How about adding a degree of obfuscation to the program? This value can be adjusted to change the *extent* to which letters can be moved around. For instance, the word: [composition] can be extremely jumbled like: [cotiioosmpn], or it can be mildly jumbled like: [copmsotioin]. This would be an interesting study to determine the degree of word jumbling that can occur but still retain elements of recognition. “”" import random import re, string “————————————–” “Definitions: ” #Function to rearrange letters in a word def shuffleWord(inWord): #Filter for 1, 2, or 3 characters if (len(inWord)<4): return inWord charList = list(inWord) #place list into new sequence firstChar = charList[0:1] lastChar = charList[len(charList)-1:] midCharList = charList[1:len(charList)-1] #—————————– #If first and last characters aren’t letters or numbers, then #scramble where the letters start if(re.match(’W', lastChar[0])): #If the last character is not a word #send first+mid Chars into this function again for processing firstAndMiddleChars = midCharList firstAndMiddleChars.insert(0, firstChar[0]) return (shuffleWord(firstAndMiddleChars)+lastChar[0]) # + means concat if(re.match(’W', firstChar[0])): midAndLastChars = midCharList midCharList.append(lastChar[0]) return (firstChar[0]+shuffleWord(midAndLastChars)) #—————————– random.shuffle(midCharList) #randomizes the middle characters #print firstChar, midCharList, lastChar #join together in one list wholeShuffledWord = midCharList wholeShuffledWord.insert(0, firstChar[0]) wholeShuffledWord.append(lastChar[0]) #print wholeShuffledWord #convert list into string and return shuffledWord = ”.join(wholeShuffledWord) #print shuffledWord return shuffledWord “————————————–” “Main program: ” “!!!! For reading from a file !!!!” “”" # Open a file, read the text inputFileHandler = open(’sometext.txt’, ‘r’) #Read into string inputFile = inputFileHandler.read() “”" “!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!” “!!!! For manual input !!!!!” inputFile = “Python is an easy to learn, powerful programming language. It has efficient high-level data ,structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.” “!!!!!!!!!!!!!!!!!!!!!!!!!!!” #Split string into and word list listWords = inputFile.split() #Scramble word for eachWord in listWords: #Split word by characters print shuffleWord(eachWord), #comma supresses newline “”" Sample output: Photyn is an esay to learn, puoerfwl pnmigrramog luganage. It has eiefifnct hilgheve-l data ,sctuuetrrs and a spmile but efeivftce apoprcah to ooerjtenb-eitcd pmoaingrrmg. Ph’tyons elgnaet synatx and damniyc tnyipg, ttehoger wtih its ietnretrped nraute, make it an iaedl lggnuaae for sncirtpig and riapd appioitclan dvlepnmeeot in many areas on msot plmtorafs. “”" My conclusions about this letter scrambling idea were very similar to the ones I found on a Cambridge University’s site explaining why this works. I also found a paper that related somewhat to this idea: Reading quickly in the periphery — the roles of lettersand sentences.Now back to work for me!View this post on my blog(Post a new comment) skilly 2004-09-30 12:08 am UTC (link) *jaw drops*(Reply to this) (Thread) mikexstudios 2004-09-30 03:30 pm UTC (link) skillet, if you are a programmer, the above program doesn’t seem at all too impressive. One day, you’ll be able to read the code like a book.(Reply to this) (Parent) (Thread) skilly 2004-09-30 09:15 pm UTC (link) Well…looking at it without knowing anything about programming…it looks quite complicated! ^^;; [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*