Solve more problems road to 200.

This commit is contained in:
2024-05-04 09:24:18 -04:00
parent 5ce2c5bcbf
commit a07f34075b
6 changed files with 182 additions and 1 deletions

25
python/e164.py Normal file
View File

@@ -0,0 +1,25 @@
from functools import lru_cache
@lru_cache
def count(last, left):
if left == 0:
return 1
c = 0
for d in range(10):
if sum(last) + d <= 9:
c += count((last[-1], d), left - 1)
return c
def euler_164():
c = 0
for d in range(1, 10):
c += count((d, ), 20-1)
return c
if __name__ == "__main__":
solution = euler_164()
print("e164.py: " + str(solution))
assert solution == 378158756814587