Created
April 21, 2016 16:13
-
-
Save chris-wood/9202048b72ce8e2188d2112b71ec8af8 to your computer and use it in GitHub Desktop.
number of partitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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