[seqfan] Re: The Bad Neighbors Sequence
Ruud H.G. van Tol
rvtol at isolution.nl
Mon Jun 17 10:38:26 CEST 2024
And now a more fundamental correction:
{ my(N=32, r=List(), v=vector(N,i,i), w=matrix(N,N,r,c,(r>1 &&
c==r-1)||(r<N && c==r+1)));
while(1
, my(p=v[1], q=3);
listput(r, p);
while(q < N && (w[v[q],p] || w[v[q+1],p]), q++);
if(q < N
, for(i=2,q, v[i-1]=v[i]);
v[q]= p;
w[p, v[q-1]]= w[p, v[q+1]]= w[v[q-1], p]= w[v[q+1], p]= 1;
, listput(r, 0);
break;
);
);
Vec(r)
}
which produces:
1, 2, 3, 1, 4, 2, 5, 3, 6, 1, 5, 7, 4, 6, 8, 2, 7, 9, 3, 8, 10, 1, 9,
11, 8, 5, 10, 12, 9, 4, 11, 13, 10, 2, 12, 6, 9, 14, 2, 11, 3, 13, 7,
10, 6, 11, 15, 3, 12, 14, 8, 13, 1, 12, 16, 13, 9, 15, 13, 5, 14, 1, 17,
10, 14, 16, 4, 15, 18, 16, 2, 15, 17, 19, 16, 11, 18, 7, 0
or reformatted:
_1,
_2,
_3, 1,
_4, 2,
_5, 3,
_6, 1, 5,
_7, 4, 6,
_8, 2, 7,
_9, 3, 8,
10, 1, 9,
11, 8, 5, 10,
12, 9, 4, 11,
13, 10, 2, 12, 6, 9,
14, 2, 11, 3, 13, 7, 10, 6, 11,
15, 3, 12, 14, 8, 13, 1, 12,
16, 13, 9, 15, 13, 5, 14, 1,
17, 10, 14, 16, 4, 15,
18, 16, 2, 15, 17,
19, 16, 11, 18, 7,
0
-- Ruud
P.S. Both previous versions were not checking enough neighbors.
More information about the SeqFan
mailing list