project-euler/116_red_green_blue_tiles.py

19 lines
315 B
Python
Raw Normal View History

2023-03-26 17:35:02 +02:00
#!/usr/bin/env python3
# Modified 115
def main(n):
return p(2, n) + p(3, n) + p(4, n) - 3
def p(m, n, tbl=False):
if n < m:
return 1
if tbl==False:
tbl = []
if n-m >= len(tbl):
r = p(m, n-1, tbl) + p(m, n-m, tbl)
tbl.append(r)
return tbl[n-m]
print(main(50))