Help:=proc(): print(`V1(L), IsOld(L), NuM(L), Comps(n,k) `): end: #V1(L):Inputs a sequence of non-neg. integers #and performs one step n Eric Angelini's #(see A151986)'s glass worms game V1:=proc(L) local i,k: k:=L[1]: if nops(L)la do od: true,[op(i..nops(L),L)]: end: #NuM(L): inputs a sequence of non-neg. integers and #outputs either the CYCLE,#MovesToGetThere #or FAIL,#MovesToGetThere NuM:=proc(L) local Orb,L1,asya: asya:=convert(L,`+`)+1: L1:=[op(L),0$asya]: Orb:=[L]: while L1<>FAIL and not IsOld(Orb)[1] do L1:=V1(L1): Orb:=[op(Orb),L1]: od: if L1=FAIL then RETURN(FAIL,nops(Orb)-1): else RETURN(IsOld(Orb)[2],nops(Orb)-1): fi: end: #all the vectors of non-neg. integers of length k #that sum up to n Comps:=proc(n,k) local L,S,b,S1,s1: option remember: if k=0 then if n=0 then RETURN({[]}): else RETURN({}): fi: fi: if n<0 then RETURN({}): fi: S:={}: for b from 0 to n do S1:=Comps(n-b,k-1): S:= S union {seq([op(s1),b], s1 in S1)}: od: S: end: