Did you ever come across the finding that even if the order of letters in words is changed just slightly you will most likely be able to read the text without much problems? I think that this is so interesting that I invested a considerable amount of time writing a software that reads a text, changes the words and outputs the result. Easier said than done, this post tries to explain what I’ve been working on.
How exactly do you want to rearrange the letters in the words? How do you calculate whether a word has more changes compared to the original word than another one? Permutations, the Hamming and Levenshtein distances come to the rescue. I implemented the Steinhaus–Johnson–Trotter algorithm to calculate permutations and almost copied variants of the distance algorithms from somebody else.
When the software now reads a text it extracts the individual words, calculates all permutations of the letters and selects either a word with a small or large Levenshtein distance based on the user’s input. This way we can either generate a variant of the text that’s pretty easy or really hard to read. Since it might not be possible to calculate permutations for long words due to performance reasons the software may fall back to a Fisher–Yates shuffle.
Try running the software with a certain text yourself but from what I’ve seen so far it is really no problem to read a variant of a certain text if some letters are rearranged. If the Levenshtein distance is at its maximum or the letters are ordered by pure chance it may really get difficult though.
For example lets use the first sentence of the last section. Right now, the result looks like the following:
How eactlxy do you wnat to rearrgnae the ltteers in the wodrs? How eltaxcy do you wnat to rgnaaerre the ltreets in the wrdos?
The first one uses a small, the second a larger Levenshtein distance. A future version of the software could produce words where the position of a character isn’t moved further away than one or two characters compared to its original position; this would make the words even easier to read.
It is really interesting to experiment with words and the results are stunning. In the end it is nice to see that we are able to adapt to rearranged letters in words, still being able to comprehend the text, reading it without much problems. Finally, we should wonder what our brain is capable of and try writing proper words without typos in the first place.