21
2
I'm sure most, if not all, of you have come across this at some point or another:
Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.
Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.
The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.
All other formatting must remain the same (capitalization and punctuation, etc.).
Testing text:
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.
As usual, this is a code-golf. Shortest code wins.
2
Similar to How to randomize letters in a word, though in that one only a single word needs to be scrambled whereas here it's every word in a sentence.
– Gareth – 2012-12-20T16:44:46.500I agree. The questions are similar enough that solutions for one problem can be used almost directly for the other. – primo – 2012-12-20T17:25:57.237
1Last letter is not right in
rscheearch
in your sample text. – daniero – 2012-12-20T19:26:35.353@Daniero it isn't my typo, but it is a known typo (see the link). I left the
[sic]
out of the quotes. – jdstankosky – 2012-12-20T21:21:12.64010I'd be more impressed with a program that did the reverse (i.e. input is the scrambled text). – Mr Lister – 2012-12-21T13:38:54.720
1Must the position of the apostrophe in
don't
remain in the same position? The spec saysAll other formatting must remain the same (capitalization and punctuation, etc.).
but I'm not sure how that works out here... – Gaffi – 2013-03-20T17:25:23.067