Skip to content

Instantly share code, notes, and snippets.

@chris-wood
Created April 21, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-wood/9202048b72ce8e2188d2112b71ec8af8 to your computer and use it in GitHub Desktop.
Save chris-wood/9202048b72ce8e2188d2112b71ec8af8 to your computer and use it in GitHub Desktop.
number of partitions
def num_partitions(l, k):
if k == 1:
return 1
else:
total = 0
for i in range(1, len(l)):
total += num_partitions(l[i:], k - 1)
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment