Skip to main content
edited body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for ct in')('[sin[s.count(')(')*2>=len]for c in')('[t+t==len(s):2-s.count('(')t/n]];"*2*n;print'\n'.join(r)

This builds the strings character by character, without filtering.

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 87.5 seconds with PyPy on my machine. Memory consumption is 1.6 GB with CPython and 32.35 GB with PyPy.

Test it on Ideone.

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in')('[s.count(')')*2>=len(s):2-s.count('(')/n]];"*2*n;print'\n'.join(r)

This builds the strings character by character, without filtering.

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine. Memory consumption is 1.6 GB with CPython and 3.3 GB with PyPy.

Test it on Ideone.

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for t in[s.count('(')]for c in')('[t+t==len(s):2-t/n]];"*2*n;print'\n'.join(r)

This builds the strings character by character, without filtering.

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 7.5 seconds with PyPy on my machine. Memory consumption is 1.6 GB with CPython and 2.5 GB with PyPy.

Test it on Ideone.

added 134 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in')('[s.count(')')*2>=len(s):2-s.count('(')/n]];"*2*n;print'\n'.join(r)

This builds the strings character by character, without filtering.

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine. Memory consumption is 1.6 GB with CPython and 3.3 GB with PyPy.

Test it on Ideone.

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in')('[s.count(')')*2>=len(s):2-s.count('(')/n]];"*2*n;print'\n'.join(r)

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine.

Test it on Ideone.

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in')('[s.count(')')*2>=len(s):2-s.count('(')/n]];"*2*n;print'\n'.join(r)

This builds the strings character by character, without filtering.

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine. Memory consumption is 1.6 GB with CPython and 3.3 GB with PyPy.

Test it on Ideone.

added 10 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2, 117117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in'()('[s.count('()')/n:*2>=len(s):2-s.count(')')*2<len(s)')+1]];"*2*n;print'\n'/n]];"*2*n;print'\n'.join(r)

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine.

Test it on Ideone.

Python 2, 117 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in'()'[s.count('(')/n:(s.count(')')*2<len(s))+1]];"*2*n;print'\n'.join(r)

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine.

Test it on Ideone.

Python 2, 117 116 bytes

def f(n):r='',;exec"r=[s+c for s in r for c in')('[s.count(')')*2>=len(s):2-s.count('(')/n]];"*2*n;print'\n'.join(r)

With piped output and input n = 15, this takes roughly 39 seconds with CPython and 8.5 seconds with PyPy on my machine.

Test it on Ideone.

Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading