Skip to content

Instantly share code, notes, and snippets.

@stulentsev

stulentsev/gist:1366422

Last active Oct 30, 2017
Embed
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
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