\\ points (x,y) on the boundary are counted as interior; \\ this is a conservative choice for the minimization of covered grid points inrot(x,y,w,h,sp,cp) = {my (xr=x*cp+y*sp, yr=-x*sp+y*cp); xr>=0 && xr <=w && yr>=0 && yr<=h}; \\ minimum of distance measured along coordinate axes inrotd(x,y,w,h,sp,cp) = {my (xr=x*cp+y*sp, yr=-x*sp+y*cp); min (min (xr,yr), min (w-xr,h-yr))}; a355241(w,h,repeat=1000000,tphi=-1) = { my (limit=ceil(1.5*max(w,h)), ratslope, cmin=oo, disming=0, sp, cp, phi); \\ The value of the slope tan(phi) of the side with length w can be fixed to this value \\ by specifying a value other than -1. If this call parameter is not specified, \\ the default -1 causes the slope to be determined by random search. if (tphi==-1,, sp=tphi/sqrt(1+tphi^2); cp=1/sqrt(1+tphi^2); phi=atan(tphi)); \\ loop over repetitions of random choice of translation, and \\ with tphi=-1, also of slope. for ( k=1, repeat, if ( tphi==-1, phi=Pi*random(1.0)/2; sp=sin(phi); cp=cos(phi)); my (dx=random(1.0), dy=random(1.0), n=0); for( x=-limit, limit, for(y=-1,limit, xx=x+dx; yy=y+dy; n += inrot (xx, yy, w, h, sp, cp) ) ); if ( n disming, disming = dismin; ratslope = bestappr(tan(phi),2*limit); print ([-n, dx, dy, phi, ratslope, dismin]) ) ) ); [cmin, ratslope] }; \\ Examples of calls \\ a355241(9,5) should return 41 covered grid points and slope either 1/3 or 3 \\ a355241(17,13) 215 covered points and slope either 2/3 or 3/2 - don't be too impatient, it may take a while \\ a355241(17,13,,1) will not find < 216 points