Skip to content

Instantly share code, notes, and snippets.

@supphawit
Last active July 6, 2018 02:48
Show Gist options
  • Save supphawit/44849c22a5d7c5d051a3644b4febeaa4 to your computer and use it in GitHub Desktop.
Save supphawit/44849c22a5d7c5d051a3644b4febeaa4 to your computer and use it in GitHub Desktop.
def parentheses(n,start,close,string):
if( n == close):
print (string)
return
else:
if (start > close):
parentheses(n,start,close+1,string+(")"))
if (start < n):
parentheses(n,start+1,close,string+("("))
parentheses(3,0,0,'')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment