Parenthesis Permutation: In 7 lines of Python(codebunk.com)
codebunk.com
Parenthesis Permutation: In 7 lines of Python
http://codebunk.com/bunk#-IsrtQcv125Udslem2wL
2 comments
Shame on you!
This is a very cool tool, @spicavigo! I look forward to using it in recruiting.
(l = ->(n,s=',o=0,c=0){ puts s and return if s.length == n || l.call(n,s+')',o,c+1) || o<n/2 && l.call(n,s+'(',o+1,c) if o>=c }).call(6)