Skip to content

Instantly share code, notes, and snippets.

@sahib
Created December 11, 2011 22:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sahib/1463064 to your computer and use it in GitHub Desktop.
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