Fix parenthesizations.py
This commit is contained in:
parent
69a605c8fc
commit
e396eb5bf4
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user