[seqfan] Re: Lattice Squares

Richard Mathar mathar at strw.leidenuniv.nl
Sat Jul 18 19:50:30 CEST 2009

Continuing on
http://list.seqfan.eu/pipermail/seqfan/2009-July/001915.html

ftaw> From seqfan-bounces at list.seqfan.eu Sat Jul 18 18:36:00 2009
ftaw> To: seqfan at list.seqfan.eu
ftaw> Date: Sat, 18 Jul 2009 12:28:35 -0400
ftaw> From: franktaw at netscape.net
ftaw> Subject: [seqfan]  Lattice Squares
ftaw> ...
ftaw> Richard, you appear to be assuming that the squares are aligned with
ftaw> the lattice.  If we don't make this assumption, there are two more for
ftaw> n=2:
ftaw>
ftaw> .X...
ftaw> ....X
ftaw> .....
ftaw> X....
ftaw> ...X.
ftaw>
ftaw> and its mirror image.

...this explains all of the difference. If I run a blind full
search including squares with non-horizontal or non-vertical sides,
I also get 1,8,33,96,225,456,...,53600

myplot := proc(xNE,yNE,xNW,yNW,xSW,ySW,xSE,ySE,n)
for y from  n to -n by -1 do
for x from  -n to n do
if x=xNE and y = yNE then
printf("x") ;
elif x=xNW and y = yNW then
printf("x") ;
elif x=xSW and y = ySW then
printf("x") ;
elif x=xSE and y = ySE then
printf("x") ;
else
printf(".") ;
fi;

od:
printf("\n") ;
od:
printf("\n\n") ;
end:

sqs := proc(n)
a := 0 ;
for xNE from 1 to n do
for yNE from 1 to n do
for xNW from -n to -1 do
for yNW from 1 to n do
xSW := xNW-(yNW-yNE) ;
ySW := yNW-(xNE-xNW) ;
if xSW < 0 and xSW >= -n and ySW < 0 and ySW >= -n then
xSE := -xNW+xSW+xNE ;
ySE := -yNW+ySW+yNE ;
if xSE > 0 and xSE <= n and ySE < 0 and ySE >= -n then
# myplot(xNE,yNE,xNW,yNW,xSW,ySW,xSE,ySE,n) ;
a := a+1 ;
fi;
fi;
od:
od:
od:
od:
a ;
end:
for n from 1 to 20 do
print(n, sqs(n)) ;
od:

Richard J. Mathar