Solve 75 and 76 in Python.
This commit is contained in:
21
python/e076.py
Normal file
21
python/e076.py
Normal 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())
|
||||
Reference in New Issue
Block a user