You are not storing your cost any where…do like this d[p][q]=cost…after
cost=a[p][q]+(max((sumtria(a,n,p+1,q)),(sumtria(a,n,p+1,q+1)))) line in sumtria function…
You are not storing your cost any where…do like this d[p][q]=cost…after
cost=a[p][q]+(max((sumtria(a,n,p+1,q)),(sumtria(a,n,p+1,q+1)))) line in sumtria function…