This question already has an answer here:

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?


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!


marked as duplicate by Fatalize, Emigna, Neil, Martin Ender string Oct 18 '16 at 12:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Also this older challenge (although it's just for a single word). \$\endgroup\$ – 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.sort(() => .5-Math.random());
  return y[0]+z.join('')+y[y.length-1]
}).join(" "))}
  • \$\begingroup\$ 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. \$\endgroup\$ – steenbergh Oct 18 '16 at 11:56
  • \$\begingroup\$ @steenbergh updated the answer, thanks! \$\endgroup\$ – Joel Christ Oct 18 '16 at 12:02
  • \$\begingroup\$ 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. \$\endgroup\$ – manatwork Oct 18 '16 at 12:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.