For example:
"Hi! How :) are :) you? I'm :) fine.:)".magic()
=> "Hi! How are :) you? I'm fine.:)"
or
=> "Hi! How are :) you? I'm :) fine."
or
...
Only :) smiley should be supported for deletion or replacing.
Use:
Code:
class String
def magic()
len = scan(/:\)/).length
pos_to_remove = (0 ... len).to_a.sample(len / 2)
gsub(/:\)/).with_index { |_, i|
if pos_to_remove.include?(i) then "" else ":)" end
}
end
end