Help:=proc(): print(`W(m,n,S), G(m,n,S)`): end:
#W(m,n,S): the number of walks from [0,0] to [m,n]
#in the 2D square lattice using steps (in both directions)
#in the set of POSITIVE integers S. For example
#the number of Soccer games with score 7:5 is
#W(7,5,{1});
W:=proc(m,n,S) local s:
option remember:
if m<0 or n<0 then 0 elif m=0 and n=0 then 1
else add(W(m-s,n,S)+W(m,n-s,S),s in S) fi:
end:
#G(m,n,S): the number of good walks from [0,0] to [m,n]
#(the second team was never ahead)
#in the 2D square lattice using steps (in both directions)
#in the set of POSITIVE integers S. For example
#the number of good Soccer games with score 7:5 is
#G(7,5,{1});
G:=proc(m,n,S) local s:
option remember:
if m<0 or n<0 then 0 elif m=0 and n=0 then 1
elif m