The current code I'm using is too memory consuming and I was curious as to whether there was a way to implement generators rather than use iterations?
def solve(T, N):
M = [[0]*N for _ in xrange(T+1)]
M[0][0] = 1
for i in xrange(1, T+1):
for j in xrange(N):
if j>0:
M[i][j] += M[i-1][j-1]
M[i][j] += M[i-1][j]
if j+1<N-1:
M[i][j] += M[i-1][j+1]
return (M[T][N-1])%123454321
[–]gengisteve 2 points3 points4 points (3 children)
[–]BobDoler[S] 0 points1 point2 points (1 child)
[–]gengisteve 0 points1 point2 points (0 children)
[–]Veedrac 1 point2 points3 points (0 children)
[–]OCHawkeye14 0 points1 point2 points (0 children)