Guest User

Untitled

a guest
Jun 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. def shuffle s
  3. samohlasky = 'aeioulr'
  4. shuffled = ""
  5. last = 'a'
  6. s = s.downcase
  7. s.length.times { |i|
  8. pos = rand*s.length
  9. it = 0
  10. while (s[pos,1] == '*') || (samohlasky.include?(last) == samohlasky.include?(s[pos,1]))
  11. pos = rand*s.length
  12. it += 1
  13. break if it > 100 && s[pos, 1] != '*'
  14. end
  15. shuffled << s[pos,1]
  16. last = s[pos,1]
  17. s[pos] = '*'
  18. }
  19. shuffled
  20. end
  21.  
  22.  
  23. p %w{Use Pastie in your quest to save humanity, not in your evil plots to take over the world!}.
  24. collect { |word| shuffle word }.join(" ")
  25.  
  26.  
  27.  
  28. outputs something like:
  29.  
  30. "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