Help:=proc(): print(`TomJc(S,F,k), Tom(n,k), Mirror(S,n,k),`): print(` CleanUp(S,n,k), PRT(N,k) `):end: Tom:=proc(n,k) local i,S: S:=TomJc({seq(i,i=0..n*k-1)},{},k): if S={} then RETURN(S): fi: S:=CleanUp(S,n,k): {seq(Sort1(S[i]),i=1..nops(S))}: end: #Inputs a set of integers S and a set #of forbidden spacings, finds all #partitions of S into mutually disjoint #Arith. progression of size k with different #spacings and avoiding the spacings in F #what we really want TomJC({0,..., n*k-1},{}); TomJc:=proc(S,F,k) local Big1,Allow1,S1,a,r,buddies,j,S2,F2,S3,i: if S={} then RETURN({{}}): fi: Big1:=trunc((max(op(S))-min(op(S)))/(k-1)): Allow1:={seq(i,i=1..Big1)} minus F: S1:={}: a:=min(op(S)): for i from 1 to nops(Allow1) do r:=Allow1[i]: buddies:={seq(a+j*r,j=0..k-1)}: if buddies subset S then S2:=S minus buddies: F2:=F union {r}: S3:=TomJc(S2,F2,k): S1:=S1 union { seq( { op(S3[j]), buddies }, j=1..nops(S3))}: fi: od: S1: end: Mirror1:=proc(S,n,k) local i: {seq(n*k-1-S[i],i=1..nops(S))}: end: Mirror:=proc(S,n,k) local i: {seq(Mirror1(S[i],n,k),i=1..nops(S))}: end: Sort1:=proc(S) local T,i,gu: gu:=[]: for i from 1 to nops(S) do gu:=[op(gu),S[i][1]]: T[S[i][1]]:=S[i]: od: gu:=sort(gu): [seq(convert(T[gu[i]],list) ,i=1..nops(gu))]: end: CleanUp:=proc(S,n,k) local S1,S2: if S={} then RETURN(S): fi: S2:=S: S1:={}: while S2<>{} do S1:=S1 union {S2[1]}: S2:=S2 minus {S2[1],Mirror(S2[1],n,k) }: od: S1: end: #PRT(N,k): all perfect rhythmic tilings of size k, of [0,n*k-1[ #for n<=N PRT:=proc(N,k) local n,S: for n from 2 to N do S:=Tom(n,k): if S<>{} then print(`There are`, nops(S), `distinct Perfect Rythmic Tilings of the integers `, [0,n*k-1]): print(` (and their mirror-images) . Here there are`): print(S): fi: od: end: