What is Typoglycemia?
Typoglycemia is a term that refers to the phenomenon where readers are able to understand text even when the letters in the middle of words are jumbled, as long as the first and last letters of each word remain in their correct positions. For example,
Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno’t mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae.
The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm.
Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? Yaeh, and I awlyas tghuhot slpeling was ipmorantt!
However, in this challenge we will implement a minor variation.
Typo Injection Rules
For each sentence, errors will be injected into words longer than four letters. All such words will contain exactly one error. All words with four letters or less will contain no errors.
For example, here are the simple rules applied to this sentence:
The boy could not solve the problem so he asked for help.
|Swap the first two letters of the word.
|The boy oculd not oslve the rpoblem so he saked for help.
|Swap the second and third letters of the word.
|The boy cuold not slove the porblem so he aksed for help.
|For even-length words, swap the middle two letters.
For odd-length words, swap the left-of-middle and middle letters.
|The boy cuold not slove the prbolem so he aksed for help.
|Swap the third- and second-to-last letters of the word.
|The boy colud not sovle the probelm so he asekd for help.
|Swap the last two letters of the word.
|The boy coudl not solev the problme so he askde for help.
Input a sentence and start with rule 0 for the first word, regardless of its length. If a word has
four or fewer letters, skip modifying it but still advance to the next rule when moving to the next word in the sentence. Cycle through the rules 0-4 for each eligible word and repeat the cycle as necessary until the end of the sentence.
A sentence with each word modified according to the applicable rule.
The quick brown fox jumps over the lazy dog.
The qiuck borwn fox jumsp over the lazy dog.
According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole.
cAcording to a researcehr at aCmbridge Uinversity, it does'nt mattre in what odrer the lettesr in a word are, the only ipmortant tihng is that the frist and last lettre be at the rihgt plac.e The rest can be a ottal mess and you can tsill read it withuot proble.m This is beacuse the humna mind does not read eveyr eltter by iteslf but the word as a whoel.