|
|
A275609
|
|
Square spiral in which each new term is the least nonnegative integer distinct from its (already assigned) eight neighbors.
|
|
22
|
|
|
0, 1, 2, 3, 1, 2, 1, 3, 2, 0, 3, 0, 1, 4, 0, 2, 0, 3, 0, 3, 0, 2, 0, 1, 3, 1, 2, 1, 2, 3, 0, 2, 3, 1, 3, 1, 2, 4, 1, 2, 1, 2, 1, 3, 1, 3, 2, 0, 2, 0, 3, 0, 3, 0, 1, 2, 1, 3, 1, 0, 2, 0, 4, 0, 1, 3, 0, 3, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 3, 1, 3, 1, 2, 1, 2, 1, 2, 3, 0, 3, 0, 2, 0, 2, 3, 1, 3, 1, 2, 3, 0, 2, 4, 1, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
"Neighbor" here means the eight cells surrounding a cell (cells that are a chess king's move away). The number assigned to a cell is the mex of the numbers that have already been assigned to any of its eight neighbors. - N. J. A. Sloane, Mar 24 2019
The largest element is 4 and it is also the element with lower density in the spiral.
[Proof that 4 is the largest term. When the spiral is being filled in, the maximal number of its neighbors that have already been filled in is four. The mex of four nonnegative numbers is at most 4. QED - N. J. A. Sloane, Mar 24 2019]
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
Illustration of initial terms as a spiral (n = 0..168):
.
. 1 - 2 - 1 - 0 - 4 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1
. | |
. 3 0 - 3 - 2 - 1 - 3 - 1 - 3 - 2 - 0 - 2 - 0 2
. | | | |
. 1 2 1 - 0 - 4 - 0 - 2 - 0 - 1 - 3 - 1 3 1
. | | | | | |
. 0 4 3 2 - 1 - 3 - 1 - 3 - 2 - 0 2 0 2
. | | | | | | | |
. 3 1 0 4 0 - 2 - 0 - 4 - 1 3 1 3 1
. | | | | | | | | | |
. 0 2 3 1 3 1 - 3 - 2 0 2 0 2 0
. | | | | | | | | | | | |
. 3 1 0 2 0 2 0 - 1 3 1 3 1 3
. | | | | | | | | | | |
. 0 2 3 1 3 1 - 3 - 2 - 0 2 0 2 0
. | | | | | | | | |
. 3 1 0 2 0 - 2 - 0 - 1 - 3 - 1 3 1 3
. | | | | | | |
. 0 2 3 1 - 3 - 1 - 3 - 2 - 0 - 2 - 0 2 0
. | | | | |
. 3 1 0 - 2 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1 3
. | | |
. 0 2 - 3 - 1 - 3 - 1 - 3 - 2 - 0 - 2 - 0 - 2 - 0
. |
. 1 - 4 - 0 - 2 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1 - 3
.
a(13) = 4 is the first "4" in the sequence and its four neighbors are 3 (southwest), 2 (south), 0 (southeast) and 1 (east) when a(13) is placed in the spiral.
a(157) = 4 is the 6th "4" in the sequence and it is also the first "4" that is below the NE-SW main diagonal of the spiral (see the second term in the last row of the above diagram).
|
|
MAPLE
|
fx:= proc(n) option remember; `if`(n=1, 0, (k->
fx(n-1)+sin(k*Pi/2))(floor(sqrt(4*(n-2)+1)) mod 4))
end:
fy:= proc(n) option remember; `if`(n=1, 0, (k->
fy(n-1)-cos(k*Pi/2))(floor(sqrt(4*(n-2)+1)) mod 4))
end:
b:= proc() -1 end:
a:= proc(n) option remember; local x, y, s, m;
x, y:= fx(n+1), fy(n+1);
if n>0 then a(n-1) fi;
if b(x, y) >= 0 then b(x, y)
else s:= {b(x+1, y+1), b(x-1, y-1), b(x+1, y-1), b(x-1, y+1),
b(x+1, y ), b(x-1, y ), b(x , y+1), b(x , y-1)};
for m from 0 while m in s do od;
b(x, y):= m
fi
end:
|
|
MATHEMATICA
|
fx[n_] := fx[n] = If[n == 1, 0, Function[k, fx[n - 1] + Sin[k*Pi/2]][Mod[ Floor[Sqrt[4*(n - 2) + 1]], 4]]];
fy[n_] := fy[n] = If[n == 1, 0, Function[k, fy[n - 1] - Cos[k*Pi/2]][Mod[ Floor[Sqrt[4*(n - 2) + 1]], 4]]];
b[_, _] := -1;
a[n_] := a[n] = Module[{x, y, s, m}, {x, y} = {fx[n + 1], fy[n + 1]}; If[n > 0, a[n - 1]]; If [b[x, y] >= 0, b[x, y], s = {b[x + 1, y + 1], b[x - 1, y - 1], b[x + 1, y - 1], b[x - 1, y + 1], b[x + 1, y], b[x - 1, y], b[x, y + 1], b[x, y - 1]}; For[m = 0, MemberQ[s, m], m++]; b[x, y] = m]];
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|