Skip to content

Instantly share code, notes, and snippets.

@yyong37
Created June 26, 2017 01:40
Show Gist options
  • Save yyong37/e1247a36079f28dbe8155bd24cacd945 to your computer and use it in GitHub Desktop.
Save yyong37/e1247a36079f28dbe8155bd24cacd945 to your computer and use it in GitHub Desktop.
def split(x):
def sp(n,m):
if m>n:
raise StopIteration
else:
for i in range(m,n//2+1):
for l in sp(n-i,i):
yield [i]+l
yield [n]
for i in sp(x,1):
print(i)
split(6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment