OFFSET
1,3
COMMENTS
The location of the bottom-left corner of the square is given. We choose the x-coordinate to be as small as possible. The x-coordinate can be negative if the n x n square is centered on the y-axis, as is the case for n = 5 and n = 13. The square is on the line y = x when n = 1, 2, 12, and 14. The Mathematica program prints the minimum (x,y) point and its squared distance from the origin.
LINKS
MATHEMATICA
nn = 1000; offset = 15; z = Table[If[PrimeQ[i + j*I, GaussianIntegers -> True], 1, 0], {i, -offset, nn}, {j, -offset, nn}]; off1 = offset + 1; done = False; sz = 0; While[! done, sz++; mn = Infinity; best = {}; Do[sm = 0; Do[sm = sm + z[[i + ii - 1, j + jj - 1]]; If[sm > 0, Break[]], {ii, sz}, {jj, sz}]; If[sm == 0, d = (i - off1)^2 + (j - off1)^2; If[d <= mn, mn = d; best = {i - off1, j - off1}]], {i, off1 - sz, nn - 1}, {j, i, nn - 1}]; If[mn < Infinity, Print[{Sort[best], mn}], done = True]]
CROSSREFS
KEYWORD
sign,more,hard
AUTHOR
T. D. Noe, May 04 2013
STATUS
approved