Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shuffle s
- samohlasky = 'aeioulr'
- shuffled = ""
- last = 'a'
- s = s.downcase
- s.length.times { |i|
- pos = rand*s.length
- it = 0
- while (s[pos,1] == '*') || (samohlasky.include?(last) == samohlasky.include?(s[pos,1]))
- pos = rand*s.length
- it += 1
- break if it > 100 && s[pos, 1] != '*'
- end
- shuffled << s[pos,1]
- last = s[pos,1]
- s[pos] = '*'
- }
- shuffled
- end
- p %w{Use Pastie in your quest to save humanity, not in your evil plots to take over the world!}.
- collect { |word| shuffle word }.join(" ")
-
- outputs something like:
- "seu sitape ni yruo qetus to save taniyum,h ton ni yruo veli tlsop to take vreo teh drwo!l"
Add Comment
Please, Sign In to add comment