project-euler/117_red_green_blue_tilesII.py

16 lines
300 B
Python

#!/usr/bin/env python3
# See 116
def p(ms, n, tbl=False):
if n < min(ms):
return n>=0
if tbl==False:
tbl = []
if n-min(ms) >= len(tbl):
r = p(ms, n-1, tbl) + sum(p(ms, n-m, tbl) for m in ms)
tbl.append(r)
return tbl[n-min(ms)]
print(p((2,3,4), 50))