Here's a simple solution to the first part.  This follows the assumption 
laid out the machine drops one (and only one) bracket.  Also assumes 
input is a command line argument or comes from standard input.

desc = ARGV[0] || $stdin.gets.chomp
exit 1 if ((desc.scan(/[\[\]{}()]/).length % 2) == 1)
puts desc