Fix parenthesizations.py

This commit is contained in:
Ivan Malison 2015-08-24 15:27:29 -07:00
parent 69a605c8fc
commit e396eb5bf4

View File

@ -3,13 +3,11 @@ from backports.functools_lru_cache import lru_cache
def parenthesizations(pairs):
parenthesizations = _parenthesizations(pairs * 2, net=0)
return call_count, parenthesizations
return parenthesizations
@lru_cache(maxsize=None)
def _parenthesizations(length, net=0):
if net > length or net < 0:
raise Exception()
if net == length:
return [')' * length]
res = prepend('(', _parenthesizations(length-1, net=net + 1))