# The brain is smarter than you think [duplicate]

As you may (or may not) know, the human brain is very good at filtering stuff out. Making things easier for us. Take the next sentence for example:

Tihs is a vrey esay seetcnne wtih smoe lnog wdros and smoe smlelar wrods

You read that pretty easily didn't you?

Good!

Now for the challenge: Write a program that takes an input (a sentence) and turns it into a sentence similar to the one above. The first and last letter of a word can not be changed, and the ones in the middle should be shuffled.

Good Luck!

• Also this older challenge (although it's just for a single word). – Zgarb Oct 18 '16 at 11:53

I'll just chime in and post my own answer

Javascript : 180 chars

function (x){console.log(x.split(" ").map(y => {
var z = y.split('')
z.pop()
z.shift()
z.sort(() => .5-Math.random());
return y[0]+z.join('')+y[y.length-1]
}).join(" "))}

• What language is this? If it's javascript, it is not a full program or function, it's assumed that x already has a value. – steenbergh Oct 18 '16 at 11:56
• @steenbergh updated the answer, thanks! – Joel Christ Oct 18 '16 at 12:02
• Please use code block markup instead of inline code markup to avoid possible escaping issues and allow scripts like Code Golf UserScript Enhancement Pack to insert the length beside the code. – manatwork Oct 18 '16 at 12:03