Created
June 12, 2011 14:48
-
-
Save paul-ihnatolia/1021627 to your computer and use it in GitHub Desktop.
Строки.rb
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
str = " Дана, строка в которой записаны слова через пробел. Необходимо перемешать в каждом слове все символы в случайном порядке кроме первого и последнего" | |
p str.delete("[.,!?]").split(" ").each {|x| n = x.split("");n.pop;n.shift;n = n.sort_by{rand};n.push(x.split("").pop);x.split("").size>1?n.unshift(x.split("").shift): n; p n.join("") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment