OFFSET
0,16
COMMENTS
EXAMPLE
n=14: one solution
{8,1,0,9,7,2,14,11,5,4,12,13,3,6,10};
n=15: three solutions
{0,9,7,2,14,11,5,4,12,13,3,6,10,15,1,8},
{5,11,14,2,7,9,0,4,12,13,3,6,10,15,1,8},
{8,1,0,9,7,2,14,11,5,4,12,13,3,6,10,15};
n=16: four solutions
{0,16,9,7,2,14,11,5,4,12,13,3,6,10,15,1,8},
{5,11,14,2,7,9,16,0,4,12,13,3,6,10,15,1,8},
{8,1,0,16,9,7,2,14,11,5,4,12,13,3,6,10,15},
{8,1,15,10,6,3,13,12,4,5,11,14,2,7,9,0,16}.
MATHEMATICA
SquareQ[n_]:=IntegerQ[Sqrt[n]]; try[lev_]:=Module[{t, j, circular}, If[lev>n+1, circular=SquareQ[soln[[1]]+soln[[n+1]]]; If[(!circular&&soln[[1]]<soln[[n+1]])||(circular&&soln[[1]]\[Equal]1&&soln[[2]]\[LessEqual]soln[[n+1]]), Print[soln]; (**)cnt++ ], (*else append another number to the soln list*)t=soln[[lev-1]]; For[j=1, j\[LessEqual]Length[s[[t+1]]], j++, If[ !MemberQ[soln, s[[t+1]][[j]]], soln[[lev]]=s[[t+1]][[j]]; try[lev+1]; soln[[lev]]=-1]]]]; nMax=30; Table[s=Table[{}, {n+1}]; Do[If[i\[NotEqual]j&&SquareQ[i+j], AppendTo[s[[i+1]], j]], {i, 0, n}, {j, 0, n}]; soln=Table[ -1, {n+1}]; cnt=0; Do[soln[[1]]=i; try[2], {i, 0, n}]; cnt, {n, 0, nMax}]
CROSSREFS
KEYWORD
hard,nice,nonn
AUTHOR
EXTENSIONS
a(42)-a(50) from Bert Dobbelaere, Dec 30 2018
STATUS
approved