Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Number 1
input = %w[therapy fun is]
string = 'therapyisfunfunfunfunis'
input.each { |k| string.gsub!(k, " #{k} ") }
string.split.join(' ')
# Number 2
# Same solution as 1
input = %w[hello world good bye]
string = 'worldgoodgoodbye'
input.each { |k| string.gsub!(k, " #{k} ") }
string.split.join(' ')
# Number 3, even possible?
input = %w[foo bar baz the therapy]
string = "oofrabzabtherapy"
# Produce the output of
"oofrabzab therapy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.