Last active
December 27, 2015 05:39
-
-
Save prat0318/7276291 to your computer and use it in GitHub Desktop.
Usage: paren(0,4,'')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Usage: paren(0,4,'') | |
def paren(sum,remaining,str): | |
if sum < 0: | |
return | |
if remaining == 0: | |
print str+')'*sum | |
return | |
paren(sum+1,remaining-1,str+'(') | |
paren(sum-1,remaining,str+')') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment