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 choose(n, k): | |
""" | |
A fast way to calculate binomial coefficients by Andrew Dalke (contrib). | |
""" | |
if 0 <= k <= n: | |
ntok = 1 | |
ktok = 1 | |
for t in xrange(1, min(k, n - k) + 1): | |
ntok *= n | |
ktok *= t |
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 fib_n_step_aux(n, k, memo): | |
if k <= 0: | |
return 0 | |
if k in [1, 2]: | |
return 1 | |
if k not in memo: | |
res = 0 | |
for i in range(1, n + 1): | |
res += fib_n_step_aux(n, k - i, memo) | |
memo[k] = res |
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
/* | |
* $status = { | |
* "status": "online" | "offline", | |
* "cover": "open" | "closed", (opt) | |
* "feeding": "feeding" | "not", (opt) | |
* "autocutterError": "error" | "not", (opt) | |
* "unrecoverableError": "error" | "not", (opt) | |
* "recoverableError": "error" | "not", (opt) | |
* "paper": "paperEnd" | "paperPresent" (opt) | |
* } |