euler/python/e117.py

31 lines
592 B
Python
Raw Normal View History

2023-10-03 20:53:27 +02:00
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)