Gautam Dey <gdey / mac.com> writes:

> Here is my solution,

and this is mine, actually quite different from the ones I saw; it
uses gsubs to reduce step-by-step.


def unwrap(desc)
  [desc.gsub!('BB',  'B'), desc.gsub!('(B)', 'B'),
   desc.gsub!('[B]', 'B'), desc.gsub!('{B}', 'B')].nitems > 0
end

def valid?(desc)
  desc = desc.dup
  true  while unwrap desc
  desc == "B" 
end

packet = ARGV.first.to_s
if valid? packet
  puts packet
  exit 0
else
  exit 1
end


-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org