(*{{3,8,9},{2,4,16}};

For comments see the music349vs2816 file, whihc runs the same way.
 *)

Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

L=Expand[Cyclotomic[8,x]];

n=16;

B=Array[0&,Length[L]];
For[j=2, j≤Length[L], B[[j]]=Mod[L[[j,2]],n];
j++];
B⋃{}



Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

n=16;


B={0,4}

Length[B];

Tile=Array[0&,1000000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile




Dynamic[{h,p,k,j,m,e}]
n=144;
w={-1,Exp[I 2 Pi /6],Exp[I 2 Pi /12],Exp[I 2 Pi /48],Exp[I 2 Pi /18],Exp[I 2 Pi /36],Exp[I 2 Pi /144],Exp[I 2 Pi /24],Exp[I 2 Pi /72]};
log={2,6,12,48,18,36,144,24,72}; 
KK={{0,1,2,3,8,9,10,11},{0,1,2,7,8,9,10,15},{0,1,3,6,8,9,11,14},{0,1,6,7,8,9,14,15},{0,2,3,5,8,10,11,13},{0,2,5,7,8,10,13,15},{0,3,5,6,8,11,13,14},{0,5,6,7,8,13,14,15}};
TILE=Array[1&,100000];
Tilea=Array[0&,60000];
Tileb=Array[0&,{60000,10}];
h=1;
e=1;
For[p=1,p≤Length[KK],
For[k=0,k≤8,
For[j=0, j≤8,If[(p>1)∨(j>0)∨(k>0) ,Tilec=Drop[Tileb⋃{},1];
For[d=1,d≤Length[Tilec],
TILE[[e]]=Catch[Do[If[Tileb[[ii]]==Tilec[[d]], Throw[Tilea[[ii]]]],{ii,Length[Tileb]}]];e=e+1;
d++];
 h=1;Tilea=Array[0&,60000];Tileb=Array[0&,{60000,8}]];
For[m=0,m≤8, 
For[m2=0,m2≤8,
For[m3=0,m3≤8,
For[m4=0,m4≤8,
For[m5=0,m5≤8,
Tilea[[h]]={0,16k+KK[[p,2]],16j+KK[[p,3]],16m+KK[[p,4]],16m2+KK[[p,5]],16m3+KK[[p,6]], 16m4+KK[[p,7]],16m5+KK[[p,8]] }⋃{};P=Tilea[[h]]; MAX=Max[P[[2]], P[[3]]-P[[2]],P[[4]]-P[[3]],P[[5]]-P[[4]],P[[6]]-P[[5]],P[[7]]-P[[6]],P[[8]]-P[[7]],144-P[[8]]];
If[MAX==P[[2]],
For[i=1,i≤9,
If[1+w[[i]]^P[[2]]+w[[i]]^P[[3]]+w[[i]]^P[[4]]+w[[i]]^P[[5]]+w[[i]]^P[[6]]+w[[i]]^P[[7]]+w[[i]]^P[[8]]==0, Tileb[[h,i]]=log[[i]]];
i++]];
Tileb[[h]]=Drop[Tileb[[h]]⋃{},1];h=h+1;
m5++];
m4++];
m3++];
m2++];
m++];
j++];
k++];
p++];

Tilea=Drop[Tilea⋃{0},1];
Length[Tilea];
TILE=Drop[TILE⋃{0},1];
Length[TILE]
TILE;

TILE=Drop[TILE,1];
Length[TILE]
For[j=1, j≤Length[TILE], P=TILE[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[TILE,Mod[P-P[[i]],n]⋃{}], TILE[[j]]=0;i=Length[P]+1];
i++];
j++]; 
TILE=Drop[TILE⋃{0},1];
Length[TILE]
TILE;

Dynamic[{j,v,vvv,vvvv}]

T2=TILE;

Clear[H];

Length[T2]

H=Array[0&,{Length[T2],144}];
MF=Array[0&,100];
MT=Array[0&,100];

For[j=1, j≤Length[T2], 
For[k=1, k≤144,
If[MemberQ[T2[[j]],Mod[k,144]],H[[j,k]]=1];
k++];
j++];

MF[[1]]=H[[1]];
MT[[1]]=T2[[1]];

cont=1;
v=1;
For[j=2, j≤Length[T2], cont=1;
For[c=1,c≤v,
For[k=1, k≤144,
If[(Not[Chop[Fourier[MF[[c]]]][[k]]==Chop[Fourier[H[[j]]]][[k]]])∧(Chop[Fourier[MF[[c]]]][[k]]==0∨Chop[Fourier[H[[j]]]][[k]]==0), 
k=145;cont=cont+1];
k++];
c++];
If[cont==v+1, MF[[v+1]]=H[[j]];MT[[v+1]]=T2[[j]]; v=v+1];
j++]; 


MT=Drop[MT⋃{},1]
MF=Drop[MF⋃{},1]
Length[MF]

J=MF;
F1=Array[1&,{Length[J],144}];

For[i=1,i<=Length[J],
For[j=1,j≤144,
If[Chop[Fourier[J[[i]]]][[j]]==0, F1[[i,j]]=0];
j++];
i++];


F1;

FF1=Array[0&,{Length[F1],144}];

For[i=1,i≤Length[F1],
For[j=1,j≤144,
If[F1[[i,j]]==0, FF1[[i,j]]=j];
j++];
i++];

For[j=1,j≤Length[FF1],
FF1[[j]]=Drop[FF1[[j]]⋃{},1];
j++];
FF1;

FF=FF1-1;

For[m=1,m≤Length[FF1],
For[j=1,j≤Length[FF1[[m]]],
FF[[m,j]]=GCD[FF[[m,j]],144];
j++];
m++];
FF;
For[j=1,j≤Length[FF],
FF[[j]]=FF[[j]]⋃{};
j++];
FF

FT=144/FF
CFT=Array[0&,Length[FT]];
For[j=1,j≤Length[FT],
CFT[[j]]=Complement[Divisors[144],FT[[j]]];
j++];
CFT



Dynamic[{jj,j,i,g, mark, rr}]
Clear[n,J,B,R,Tile,A,U,mark,T,g,x];

n=144;

J={{0,19,38,56,73,91,110,129},{0,21,39,58,72,93,114,127},{0,21,40,51,70,91,109,126},{0,21,40,58,77,95,114,135},{0,22,40,55,73,95,113,126},{0,22,40,57,75,97,115,126},{0,22,40,62,81,103,121,143},{0,23,41,63,81,86,104,126},{0,24,26,50,55,79,101,125},{0,24,26,50,71,95,105,129},{0,24,29,53,66,90,107,131},{0,24,30,54,57,81,99,123},{0,24,33,54,57,78,99,123},{0,24,35,59,81,98,105,122},{0,24,45,69,90,99,114,123},{0,24,47,54,71,78,101,125},{0,27,38,65,78,104,105,131},{0,27,51,54,72,81,105,126}};
rr=1;
gcd=Array[0&,{Length[J],Length[J[[1]]]}];
For[kk=1,kk≤Length[J],
For[mm=2,mm≤Length[J[[kk]]],
gcd[[kk,mm]]=GCD[gcd[[kk,mm-1]],J[[kk,mm]]];
mm++];
kk++];
For[kk=1,kk≤Length[J], gcd[[kk,Length[J[[1]]]]]=GCD[gcd[[kk,Length[J[[1]]]]],n];
kk++];

maxperiod=Array[0&,{Length[J],10000}];

For[jj=1, jj≤Length[J],Clear[B,R,Tile,A,U,mark,T,g,x];n=144;n=n/gcd[[jj, Length[J[[1]]]]];B=J[[jj]]/gcd[[jj,Length[J[[1]]]]];

Tile=Array[0&,100000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};maxperiod[[jj,g]]=99;
For[ff=Length[Divisors[n]]-1, ff>0,
If[Mod[((Divisors[n][[ff]])+Tile[[g]]),n]⋃{}==Tile[[g]],Tile[[g]]=0;maxperiod[[jj,g]]=Divisors[n][[ff]];ff=0;
 ];
ff=ff-1];
 g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{0},1];
Length[Tile]
Tile;

For[j=1, j≤Length[Tile], P=Tile[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[Tile,Mod[P-P[[i]],n]⋃{}], Tile[[j]]=0;i=Length[P]+1];
i++];
j++]; 
Tile=Drop[Tile⋃{0},1];
If[Not[Length[Tile]==0], rr=rr+1];
Tile;
jj++];
rr

For[j=1,j≤Length[maxperiod],maxperiod[[j]]=Drop[maxperiod[[j]]⋃{0},1];
j++];
maxperiod