Task:

 Generate a string with   N   opening brackets   [   and with   N   closing brackets   ],   in some arbitrary order. 
 Determine whether the generated string is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), none of which mis-nest.


Examples

   (empty)      OK
   []           OK   
   [][]         OK   
   [[][]]       OK 
   ][         NOT OK
   ][][       NOT OK
   []][[]     NOT OK



isBalanced: function [s][
	cnt: 0
 
	loop split s [ch][
		if? ch="]" [
			cnt: cnt-1
			if cnt<0 -> return false
		]
		else [
			if ch="[" -> cnt: cnt+1
		]
    ]
 
    cnt=0
]
 
loop 1..10 'i [
	str: join map 0..(2*i)-1 [x][ sample ["[" "]"]]
 
	prints str
 
	if? isBalanced str  -> print " OK"
	else 				-> print " Not OK"
]