Skip to content

Instantly share code, notes, and snippets.

@ideamonk
Created October 24, 2010 16:38
Show Gist options
  • Save ideamonk/643663 to your computer and use it in GitHub Desktop.
Save ideamonk/643663 to your computer and use it in GitHub Desktop.
Q1 of BORQ
# solution to simpler part
# puts gets.chop.gsub!( /\(\([^))]*\)\)/) { |w| w=gets.chop}
# part 2 - along with substitution
dict = {}
puts IO.read(ARGV.shift).chop.gsub!( /\(\([^))]*\)\)/) { |w|
w = w.scan(/[^()]+/)[0]
combo = w.split(":")
if (combo.size==2)
print "Enter #{combo[1]} : "
w = dict[combo[0]] = gets.chop
else
if (dict[combo[0]] == nil)
print "Enter #{combo[0]} : "
w=gets.chop
else
w = dict[combo[0]]
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment