Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
Created October 30, 2019 03:20
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 mark-d-holmberg/9c26de37b0666204ceb6951323eb1faf to your computer and use it in GitHub Desktop.
Save mark-d-holmberg/9c26de37b0666204ceb6951323eb1faf to your computer and use it in GitHub Desktop.
# 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