def parentmatched(inputstring)
while inputstring != nil
p inputstring
break if (inputstring.gsub!(/\(\)/, '')==nil)
end
if inputstring.eql?('')
puts "matched"
else
puts "non-matched"
end
end
parentmatched("((())(())()(()))()");
No comments:
Post a Comment