Skip to content

Instantly share code, notes, and snippets.



Last active Oct 30, 2017
What would you like to do?
Британские ученые text maker
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[0] + # first letter
word[1..-2].chars.shuffle.join('') +
word[-1] # last letter
puts res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment