[seqfan] Re: 2D extension to A327474
Richard J. Mathar
mathar at mpia-hd.mpg.de
Fri Jan 27 11:20:54 CET 2023
I get 1, 7, 66, 383,.. for distinct centers of mass
of binary square nXn arrays of n=1,2,3,4...
The [x,y] means for n=1 are [0,0] (it does not matter whether
the cell is occupied or not, the mean is the same).
The [x,y] means for n=2 are
{[1, 1], [1/2, 1/2], [0, 0], [0, 1/2], [1/2, 0], [1/2, 1], [1, 1/2]}
brute force Maple code:
# L is a list of sequentialized positions of 1, members in the range 0..n*m-1
# n is the number of rows, m the number of columns
# by modulo and remainder division of a member of L through m
# we get the x and y positions in the range 0..m-1 and 0..n-1
Aaux := proc(L,n,m)
local xsum,ysum,lin,x,y ;
xsum := 0 ;
ysum := 0 ;
for lin in L do
x := modp(lin,m) ;
y := floor(lin/m) ;
xsum := xsum+x ;
ysum := ysum+y ;
end do:
[xsum/m,ysum/n] ;
end proc:
A := proc(n)
local xymean,n2,lpos,ones ;
xymean := {} ;
# nxn grid of 1's 2^(n^2) places ennumbered 0..2^(n^2-1)
n2 := n^2 ;
lpos := {seq(i,i=0..n2-1)} ;
for ones in combinat[powerset](lpos) do
{Aaux(ones,n,n)} ;
xymean := xymean union % ;
end do:
print(xymean) ;
nops(xymean) ;
end proc:
A(1) ;
A(2) ;
A(3) ;
A(4) ;
--
Richard J. Mathar https://www.mpia.de/~mathar
More information about the SeqFan
mailing list