Help:=proc(): print(`Games(S,n), TieLessGames(S,n) , IsBad(L)`): print(`NaiveTieLessSeq(S,N),TieLessGamesC(S,n) `): end: #Games(S,n): inputs a set of positive integers S #and a non-neg. integer n, outputs all the sequences #(lists in Maple's langauage) in +-S Games:=proc(S,n) local T1,t1,s,Sprime: option remember: if n<0 then RETURN({}): fi: if n=0 then RETURN({[]}): fi: T1:=Games(S,n-1): Sprime:=S union { seq(-s1, s1 in S)}: { seq(seq( [ op(t1), s], t1 in T1),s in Sprime) }: end: #Inputs a sequence of integers L and outputs true #if (at least) one of the non-empty partial sums is 0 IsBad:=proc(L) local i,s: s:=0: for i from 1 to nops(L) do s:=s+L[i]: if s=0 then RETURN(true): fi: od: false: end: #TieLessGames(S,n): inputs a set of positive integers S #and a non-neg. integer n, outputs all the sequences #(lists in Maple's langauage) in +-S such that #there was never a tie during the game (or the end) TieLessGames:=proc(S,n) local T,GoodGuys,t: T:=Games(S,n): GoodGuys:={}: for t in T do if not IsBad(t) then GoodGuys:=GoodGuys union {t}: fi: od: RETURN(GoodGuys): end: #NaiveTieLessSeq(S,N): the first N terms in the #counting sequence for Tie-Less games with n #events where S is the set of possible scores NaiveTieLessSeq:=proc(S,N) local n: [seq(nops( TieLessGames(S,n) ),n=1..N)]: end: #TieLessGamesC(S,n): Not-as-stupid version of TieLessGames(n,S) TieLessGamesC:=proc(S,n) local T1,Sprime,t1,T,su,S1: option remember: if n<0 then RETURN({}): fi: if n=0 then RETURN({[]}): fi: T1:=TieLessGamesC(S,n-1): Sprime:=S union {seq(-s, s in S)}: T:={}: for t1 in T1 do su:=-convert(t1,`+`): S1:=Sprime minus {su}: T:=T union {seq([op(t1),s1], s1 in S1)}: od: RETURN(T): end: #NaiveTieLessSeqC(S,N): the first N terms in the #counting sequence for Tie-Less games with n #events where S is the set of possible scores NaiveTieLessSeqC:=proc(S,N) local n: [seq(nops( TieLessGamesC(S,n) ),n=1..N)]: end: