Re: Bracket Packing (#78) (2 solutions)

James Edward G. II writes:

["()", “{}”, “[]”].each { |symbol_pair| exit(1) if 0 != ARGV
[0].count(symbol_pair) % 2 }
puts ARGV[0]

Just thinking out loud here, but how does this fair with inputs like:

“)B(” or “B()”


You’re correct, the code I provided could not deal with those
situations. However, those should never be presented as inputs
according to post 191513, which I’ll quote:

Ross B. writes:

Ie, [{(B),(B)}] -> [(B),(B)]

Good point. Let’s assume just one bracket will be missing, if any.
Obviously, to fix it, it needs to go back in the right place.