Solve 75 and 76 in Python.

This commit is contained in:
2019-08-15 23:05:39 -04:00
parent 2802f8e957
commit d9e31d69cf
2 changed files with 134 additions and 2 deletions

21
python/e076.py Normal file
View File

@@ -0,0 +1,21 @@
from functools import lru_cache
@lru_cache(maxsize=1000000)
def possible_sums(n, n_orig, d):
if d == n_orig:
return 0
if n == 0:
return 1
if n < 0:
return 0
if d > n:
return 0
return possible_sums(n - d, n_orig, d) + possible_sums(n, n_orig, d + 1)
def euler_067():
return possible_sums(100, 100, 1)
print(euler_067())