Created
March 10, 2018 06:48
-
-
Save marckohlbrugge/12d9187489d0d859307c5b2cba160f3b to your computer and use it in GitHub Desktop.
for pietz
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
text = %{This validates there's a lot of attention and real business to be made targeting the nomad and remote work space. Even if nomads have previously had an image of low-income. There's money here.} | |
def garble(input, intro: 0) | |
length = input.length | |
output = [] | |
for position in 0...length | |
percentage = (position / length.to_f) | |
output << if percentage < intro || | |
percentage < rand || | |
input[position].chr !~ /\w+/ | |
input[position].chr | |
else | |
('a'..'z').to_a[rand(26)] | |
end | |
end | |
output.join | |
end | |
# p garble(text, intro: 0.20) | |
def shuffler(input) | |
output = [] | |
words = input.split(" ") | |
words.each do |word| | |
letters = word.scan(/\w/) | |
first = letters.shift | |
last = letters.pop || "" | |
output << first + letters.shuffle.join + last | |
end | |
output.join(" ") | |
end | |
p shuffler(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment