Solve 114 through 117.

This commit is contained in:
2023-10-03 20:53:27 +02:00
parent 41f8cc1345
commit 67526f1978
4 changed files with 140 additions and 0 deletions

30
python/e117.py Normal file
View File

@@ -0,0 +1,30 @@
from functools import lru_cache
@lru_cache()
def block_combinations(row_length: int):
block_sizes = [2, 3, 4]
if row_length < 0:
return 0
if row_length == 0:
return 1
# space
result = block_combinations(row_length - 1)
# one of the blocks
for block_length in block_sizes:
result += block_combinations(row_length - block_length)
return result
def euler_117():
return block_combinations(50)
if __name__ == "__main__":
solution = euler_117()
print("e117.py: " + str(solution))
assert(solution == 100808458960497)