Last active
October 30, 2017 08:57
-
-
Save stulentsev/1366422 to your computer and use it in GitHub Desktop.
Британские ученые text maker
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 = "Today we (professors + teaching assistants) proctored a midterm exam for a class of about 80 students. There was undoubtedly a 'hardest' question on the exam, since nearly the entire classroom of students asked us how to proceed with that question. To be fair, we didn't give any hints, but it was clear that one had to use a definition to be able to proceed." | |
res = str.gsub(/\b[[:alpha:]]+\b/) do |word| | |
if word.length < 4 | |
word | |
else | |
word[0] + # first letter | |
word[1..-2].chars.shuffle.join('') + | |
word[-1] # last letter | |
end | |
end | |
puts res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment