Skip to content

Instantly share code, notes, and snippets.

@mbie
Created February 10, 2017 13:48
Show Gist options
  • Select an option

  • Save mbie/ed9f9748ab6e3e096b68f7dc49f9d3d6 to your computer and use it in GitHub Desktop.

Select an option

Save mbie/ed9f9748ab6e3e096b68f7dc49f9d3d6 to your computer and use it in GitHub Desktop.
Simple ruby script which creates anagram for words in a sentence.
string = "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program"
output = string.split.map do |word|
if word.length > 3
word[1..-2] = word[1..-2].chars.shuffle.join
end
word
end.join(" ")
puts output # Msot good paegrrmorms do pnimgormarg not bseuace they epcxet to get piad or get aaudliotn by the pbcilu, but buseace it is fun to praogrm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment