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



( (bal=|"[" !bal "]" !bal)
& ( generate
  =   a j m n z N S someNumber
    .   !arg:<1&
      |   11^123+13^666+17^321:?someNumber
        & (!arg:?n)+1:?N
        & :?S
        &   whl
          ' (!n+-1:~<0:?n&"[" "]" !S:?S)
        &   whl
          ' ( !someNumber:>0
            & mod$(!someNumber.!N):?j
            & div$(!someNumber.!N):?someNumber
            & !S:?a [!j ?m [!N ?z
            & !z !m !a:?S
            )
        & !S
  )
& 0:?L
&   whl
  ' ( generate$!L:?S
    & put$(str$(!S ":"))
    &   out
      $ (!S:!bal&Balanced|"Not balanced")
    & !L+1:<11:?L
    )
);