Skip to content

Instantly share code, notes, and snippets.

@stulentsev
Last active October 30, 2017 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stulentsev/1366422 to your computer and use it in GitHub Desktop.
Save stulentsev/1366422 to your computer and use it in GitHub Desktop.
Британские ученые 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