%I #12 Jun 30 2026 10:46:37
%S 0,1,2,3,6,4,7,15,5,8,13,31,21,10,23,11,29,14,37,30,61,26,53,27,55,42,
%T 63,43,85,46,87,47,12,28,79,95,9,25,127,111,20,62,119,18,183,126,22,
%U 38,54,190,86,110,94,174,118,175,214,191,215,58,93,59,117,106
%N Lexicographically earliest sequence of distinct nonnegative integers whose binary plot has no two 0 bits a knight's move apart.
%C A variation of A394166 where the 0 bits, as opposed to the 1 bits, cannot be a knight's move apart.
%C It is conjectured that all nonnegative numbers appear.
%H Scott R. Shannon, <a href="/A397519/b397519.txt">Table of n, a(n) for n = 0..10000</a>
%e The terms, with their binary values, begin:
%e n a(n) A007088(a(n))
%e -- ---- --------------
%e 0 0 0
%e 1 1 1
%e 2 2 10
%e 3 3 11
%e 4 6 110
%e 5 4 100
%e 6 7 111
%e 7 15 1111
%e 8 5 101
%e 9 8 1000
%e 10 13 1101
%e 11 31 11111
%e 12 21 10101
%e 13 10 1010
%e 14 23 10111
%e 15 11 1011
%e 16 29 11101
%e 17 14 1110
%e 18 37 100101
%e 19 30 11110
%e 20 61 111101
%e .
%o (Python)
%o from itertools import count, islice
%o def comp(k): return (~k)&((1<<k.bit_length())-1)
%o def agen(): # generator of terms
%o aset, m, an2, an1 = {0, 1}, 2, 0, 1
%o yield from [0, 1]
%o for n in count(2):
%o can1, can2 = comp(an1), comp(an2)
%o mask = (can1<<2)|(can1>>2)|(can2<<1)|(can2>>1)
%o an2, an1 = an1, next(k for k in count(m) if not (comp(k)&mask or k in aset))
%o yield an1
%o aset.add(an1)
%o while m in aset: m += 1
%o print(list(islice(agen(), 64))) # _Michael S. Branicky_, Jun 30 2026
%Y Cf. A394166, A007088, A396836, A109812, A396694.
%K nonn,base
%O 0,3
%A _Scott R. Shannon_, Jun 29 2026