@x @i gb_types.w @y @i gb_types.w \input epsf @z @x ullng count; /* solutions found so far */ @y ullng count; /* solutions found so far */ unsigned int max1,max2,max3; unsigned int min1=-1,min2=-1; unsigned int count1,count2,count3,count4,count5,count6,count7; @z @x fprintf(stderr,"Altogether "O"llu solution"O"s, "O"llu nodes,",@| count,count==1?"":"s",nodes); fprintf(stderr," "O"llu+"O"llu mems.\n",imems,mems); @y fprintf(stderr,"Altogether "O"llu solution"O"s, "O"llu nodes,",@| count,count==1?"":"s",nodes); fprintf(stderr," "O"llu+"O"llu mems.\n",imems,mems); fprintf(stderr,"mins "O"u,"O"u; maxs "O"u,"O"u,"O"u;\n", min1,min2,max1,max2,max3); fprintf(stderr,"counts "O"u,"O"u,"O"u,"O"u,"O"u,"O"u,"O"u.\n", count1,count2,count3,count4,count5,count6,count7); @z @x count++; if (spacing && count mod spacing==0) { nd[level].i=0,nd[level].d=1; nd[level].m=eptr; if (vbose&show_raw_sols) { printf("\n"O"llu:\n",count);@+print_state(stdout); }@+else @; fflush(stdout); } @y count++; nd[level].i=0,nd[level].d=1; nd[level].m=eptr; @; @; if (spacing && count mod spacing==0) { @; fflush(stdout); } @z @x int path[maxn+1]; /* the Hamiltonian cycle, in order */ @y int path[maxn+2]; /* the Hamiltonian cycle, in order */ int pathi[maxn+2],pathj[maxn+2]; /* the same, separated into coordinates */ int odd_area,swept_area,zeros,spread,check_area; int winding[8][8][21]; /* internal winding numbers */ int magic0[21]={0,0,-1,-1,-1,-1,-1,-1,-2,1,0,0,0,0,0,0,0,0,-1,0,-1}; /* blue */ int magic1[21]={2,2,1,2,2,2,2,2,2,1,0,0,1,1,1,1,1,2,1,2,1}; /* green */ int magic2[21]={1,0,0,1,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0}; /* red hi */ int magic3[21]={0,0,-1,0,0,0,-1,-1,-1,0,0,-1,0,0,0,0,-1,0,0,0,0}; /* red lo */ int magic4[21]={1,1,1,1,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,1,1}; /* orange hi */ int magic5[21]={2,2,1,2,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1}; /* orange lo */ int area[21]={20,1,1,1,8,12,8,1,3,12,12,3,1,8,12,8,1,1,1,3,3}; /* region size */ @z @x @*Index. @y @ @= { register int i,j,k; for (k=0;k= { register int i,j,k,ii,jj,kk,s,wmin,wmax,w,q; for (i=0;i@; else @; }@+else if (jj@; else @; } @; @; } @ @= { for (k=0;k<21;k++) { for (q=j+magic0[k];q= { for (k=0;k<21;k++) { for (q=j+magic1[k];q= { for (k=0;k<21;k++) { for (q=j+magic2[k];q= { for (k=0;k<21;k++) { for (q=j+magic4[k];q= for (zeros=swept_area=0,wmin=infty,wmax=-infty,i=1;iwmax) wmax=w; if (w; @ Long ago I discovered a surprisingly simple formula for the swept area of a polygonal path that never touches the corner points of a grid. (See {\sl The American Mathematical Monthly\/ \bf101} (1994), 682--683; {\bf104} (1997), 669.) Namely, the swept area always turns out to be an integer, equal to ${1\over2}\bigl(i_0j_1-i_1j_0+i_1j_2-i_2j_1+ \cdots+i_{mn-1}j_{mn}-i_{mn}j_{mn-1}\bigr)$. @= { if (check_area!=120*swept_area) fprintf(stderr,"This can't happen.\n"); for (check_area=k=0;k= if (odd_areamax1) max1=odd_area; if (!swept_area) { count1++; if (odd_areamax2) max2=odd_area; } else { if (swept_area<0) swept_area=-swept_area; if (swept_area>max3) max3=swept_area; } if (!zeros) count2++; else if (zeros==40) count4++; else if (zeros>40) count6++; if (spread==1) count3++; else if (spread==9) count5++; else if (spread>9) count7++; @ @= for (k=0;k<=nn;k++) printf(""O"s ",name(path[k])); printf(""O"u,"O"u,"O"u,"O"u", odd_area,swept_area,zeros,spread); printf(" #"O"llu\n",count); @ @= void print_windings(void) { register int i,j,k; for (i=0;i