From: James Edward Gray II Date: 2006-05-08T06:27:38+09:00 Subject: Re: [QUIZ] Bracket Packing (#78) (2 solutions) On May 7, 2006, at 1:36 PM, Eric I. wrote: > Here is my solution to the first option of the quiz, which is > simply to detect if there is a problem. It makes use of the > allowed assumption that only one packaging character would be > omitted in incorrect input. So the underlying algorithm is to make > sure there are an even number of combined "("s and ")"s (and the > same goes for the other two types of packaging). The String#count > method does much of the heavy lifting. > > > ["()", "{}", "[]"].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()" ? James Edward Gray II