Created
February 10, 2017 13:48
-
-
Save mbie/ed9f9748ab6e3e096b68f7dc49f9d3d6 to your computer and use it in GitHub Desktop.
Simple ruby script which creates anagram for words in a sentence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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