\def\MP{{\logo METAPOST}} \font\logo=logo10 \def\dts{\mathinner{\ldotp\ldotp}} \def\half{{1\over2}} \input epsf @*Intro. Michael Simkin defined a curious mapping from an $n\times n$ square grid to a $2N\times 2N$ square grid that has been truncated to a diamond of width $2N$, then rotated $45^\circ$. He uses this when $n\ge N^2$. For $1\le i,j\le n$, let cell $(ij)$ of the $n\times n$ grid be the open set (ij)=\{(x,y)\mid i-1N$, the nonempty Cells occur for$J=I-N$(a triangle pointing left),$I-N #include int N,n; /* command-line arguments */ int nn,Nnn; /* |n+n| and |N*nn| */ int ass[maxn][maxn]; /* if $(ij)\mapsto[IJ]$, |ass[i-1][j-1]=(I<<16)-J| */ int IJcount[2*maxN][2*maxN]; FILE *MPfile; char MPfilename[64]; @; main(int argc,char*argv[]) { register i,j,k,x,y; @; @; @; @; @; } @ @= if (argc!=3 || sscanf(argv[1],"%d", &N)!=1 || sscanf(argv[2],"%d", &n)!=1) { fprintf(stderr,"Usage: %s N n\n", argv[0]); exit(-1); } if (N<1 || N>maxN) { fprintf(stderr,"Recompile me: At present N must be between 1 and %d!\n", maxN); exit(-2); } if (n<1 || n>maxn) { fprintf(stderr,"Recompile me: At present n must be between 1 and %d!\n", maxn); exit(-2); } if (n= void IJset(int x,int xd,int y,int yd,int i,int j) { register int I,J,acc; I=(x+x+xd+y+y+yd+nn)/nn; J=(Nnn+y+y+yd-x-x-xd+nn)/nn; acc=(I<<16)-J; if (acc= for (i=0;i>16)+1) @d Jpart(a) (-(a)&0xffff) @= for (j=n-1;j>=0;j--) { for (i=0;i= for (i=0;i=0;j--) { for (i=0;i= sprintf(MPfilename,"/tmp/queenon-partition-%d-%d.mp", N,n); MPfile=fopen(MPfilename,"w"); if (!MPfile) { fprintf(stderr,"I can't open file %s' for writing!\n", MPfilename); exit(-5); } @; @; @; fprintf(stderr,"OK, I've written the METAPOST file %s'.\n", MPfilename); @ @= fprintf(MPfile,"%% produced by %s %d %d\n", argv[0],N,n); fprintf(MPfile,"N=%d; n=%d;\n", N,n); fprintf(MPfile,"numeric h,u; u=1cm; n*h=N*u;\n"); fprintf(MPfile,"primarydef x!y = (x*u,y*u) enddef;\n"); fprintf(MPfile,"\n"); fprintf(MPfile,"string ch;\n"); fprintf(MPfile,"picture pic[];\n"); fprintf(MPfile,"pic[ASCII \"W\"]=nullpicture;\n"); fprintf(MPfile,"currentpicture:=nullpicture;\n"); fprintf(MPfile,"fill (0,0)--(h,0)--(h,h)--(0,h)--cycle withcolor red;\n"); fprintf(MPfile,"pic[ASCII \"R\"]=currentpicture;\n"); fprintf(MPfile,"fill (0,0)--(h,0)--(h,h)--(0,h)--cycle withcolor blue;\n"); fprintf(MPfile,"pic[ASCII \"B\"]=currentpicture;\n"); fprintf(MPfile,"fill (0,0)--(h,0)--(h,h)--(0,h)--cycle withcolor green;\n"); fprintf(MPfile,"pic[ASCII \"G\"]=currentpicture;\n"); fprintf(MPfile,"currentpicture:=nullpicture;\n"); fprintf(MPfile,"\n"); fprintf(MPfile,"newinternal ny;\n"); fprintf(MPfile,"def row expr s =\n"); fprintf(MPfile," ny:=ny+1;\n"); fprintf(MPfile," for j=0 upto length s-1:\n"); fprintf(MPfile," ch:=substring(j,j+1) of s;\n"); fprintf(MPfile," draw pic[ASCII ch] shifted (j*h,ny*h);\n"); fprintf(MPfile," endfor\n"); fprintf(MPfile,"enddef;\n"); fprintf(MPfile,"\n"); fprintf(MPfile,"beginfig(0)\n"); fprintf(MPfile,"ny:=-1;\n"); @ @= for (j=n-1;j>=0;j--) { fprintf(MPfile,"row \""); for (i=0;i= fprintf(MPfile,"for i=0 upto n: draw (0,i*h)--(n*h,i*h); draw (i*h,0)--(i*h,n*h); endfor\n"); fprintf(MPfile,"for i=0 upto N-1:\n"); fprintf(MPfile," draw 0!i--(N-i)!N;\n"); fprintf(MPfile," draw i!0--N!(N-i);\n"); fprintf(MPfile," draw 0!(N-i)--(N-i)!0;\n"); fprintf(MPfile," draw i!N--N!i;\n"); fprintf(MPfile,"endfor\n"); fprintf(MPfile,"endfig;\n"); fprintf(MPfile,"bye.\n"); @*Index.