fork download
  1. def f(n):r='',;exec"r=[s+c for s in r for t in[s.count('(')]for c in')('[t+t==len(s):2-t/n]];"*2*n;print'\n'.join(r)
  2.  
  3. f(0)
  4. f(1)
  5. f(2)
  6. f(3)
  7. f(4)
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
()
()()
(())
()()()
()(())
(())()
(()())
((()))
()()()()
()()(())
()(())()
()(()())
()((()))
(())()()
(())(())
(()())()
(()()())
(()(()))
((()))()
((())())
((()()))
(((())))