Created
October 24, 2010 16:38
-
-
Save ideamonk/643663 to your computer and use it in GitHub Desktop.
Q1 of BORQ
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
# 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