Created
December 11, 2011 22:08
-
-
Save sahib/1463064 to your computer and use it in GitHub Desktop.
This file contains 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
def randomize str | |
out = "" | |
pos = (0..str.length-1).to_a | |
pos.each do |num| | |
new_pos = rand(str.length-1) | |
# Swap | |
tmp = pos[num] | |
pos[num] = pos[new_pos] | |
pos[new_pos] = tmp; | |
end | |
pos.each do |num| | |
out += str[num] | |
end | |
return out | |
end | |
def kittenize txt | |
out = "" | |
txt.split.each do |word| | |
out += ( word[0] + | |
randomize(word[1...(word.length-1)]) + | |
word[-1] + | |
" " | |
) | |
end | |
return out | |
end | |
puts kittenize ARGV[0] unless ARGV.size < 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment