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

**URL:** <https://www.ruby-forum.com/t/re-bracket-packing-78-2-solutions/94581>\
**Category:** Ruby\
**Created:** [May 8, 2006, 12:53am UTC](https://www.ruby-forum.com/t/re-bracket-packing-78-2-solutions/94581 "2006-05-08T00:53:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@Eric\_I](https://www.ruby-forum.com/u/Eric_I)\
**Post date:** [May 8, 2006, 12:53am UTC](https://www.ruby-forum.com/t/re-bracket-packing-78-2-solutions/94581/1 "2006-05-08T00:53:27Z")

</div>

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.

Eric
