``````//Sorting into three lists
nSrt=List.Reverse(List.Sort(n));
nSbL=List.Chop(nSrt,3);
lst1=List.Transpose(List.TakeEveryNthItem(nSbL,2,-1));
lst2=List.Transpose(List.Reverse((List.TakeEveryNthItem(nSbL,2,0))<1>));

//Three sublists with the sum of numbers more or less the same
lst3=(List.Transpose([List.Shuffle(lst1<1>),List.Shuffle(lst2<1>)]));
lst4 = List.Flatten(List.Clean(lst3,false)<1>,-1);``````
``````r1=["Room1",ar1,ad1];
Rooms=[r1,r2,r3,r4,r5,r6,r7];``````
``````//Sorting List By Adjacency Factor

//Circles
Rms=Circles.ExtrudeAsSolid(Vector.ZAxis(),1);
Clr1=Color.ByARGB(255,255,0,0);
Clr2=Color.ByARGB(255,0,255,0);
Clr3=Color.ByARGB(255,0,0,255);
Clrs=[Clr1,Clr2,Clr3];
ClrI=0..1;
ClrV=0..1..#(List.Count(Rms));``````

``````def AdjM(RmAr:var[])
{
return=[Imperative]
{
k=0;
rd=[];
cp=[];
ci=[];
dis=[];
cpd=[];
cpl=[];
cph=[];
cpx=[];
cpy=[];

for (i in RmAr)
{
if (k<2)
{
rd[k]=Math.Sqrt(i/Math.PI);
cp[0]=Point.Origin();
cp[k]=Point.ByCoordinates(rd[k]+rd[0],0);
k=k+1;
}
else
{
rd[k]=Math.Sqrt(i/Math.PI);
dis[k]=rd[k-2]+rd[k-1];
cpd[k]=Math.Sqrt(Math.Pow((cp[k-2].X-cp[k-1].X),2)+Math.Pow((cp[k-2].Y-cp[k-1].Y),2));
cpl[k]=(Math.Pow(rd[k-2]+rd[k],2)-Math.Pow(rd[k-1]+rd[k],2)+Math.Pow(cpd[k],2))/(cpd[k]*2);
cph[k]=Math.Sqrt(Math.Pow(rd[k-2]+rd[k],2)-Math.Pow(cpl[k],2));
cpx1[k]=(cpl[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+(cph[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+cp[k-2].X;
cpx2[k]=(cpl[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])-(cph[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+cp[k-2].X;
cpy1[k]=(cpl[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])-(cph[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+cp[k-2].Y;
cpy2[k]=(cpl[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+(cph[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+cp[k-2].Y;
if (cpy1[k]>=cpy2[k])
{
cpx[k]=cpx1[k];
cpy[k]=cpy1[k];
}
else
{
cpx[k]=cpx2[k];
cpy[k]=cpy2[k];
}
cp[k]=Point.ByCoordinates(cpx[k],cpy[k]);
k=k+1;
}
}
return=ci;
}
};``````
``````r1=["Room1",ar1,ad1];
Rooms=[r1,r2,r3,r4,r5,r6,r7];``````
``````//Sorting List By Adjacency Factor