solve balanced brackets in ruby
solve balanced brackets in scala