Created
September 29, 2015 10:22
-
-
Save niklasb/e350e694f50bea76ec61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
memo = {} | |
def p(n,k): | |
if (n,k) in memo: return memo[n,k] | |
if (n,k) == (0,0): return 1 | |
if n < k or (n > 0 and k == 0): return 0 | |
memo[n,k] = p(n-k,k) + p(n-1,k-1) | |
return memo[n,k] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment