TE
TechEcho
Home
24h Top
Newest
Best
Ask
Show
Jobs
English
GitHub
Twitter
Home
Parenthesis Permutation: In 7 lines of Python
3 points
by
spicavigo
about 12 years ago
2 comments
shadykiller
about 12 years ago
Collapse
Here's a 1 liner port in ruby :<p>(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)
评论 #5601106 未加载
arihersh
about 12 years ago
This is a very cool tool, @spicavigo! I look forward to using it in recruiting.