login
Numbers whose binary representation traces a nonselfcrossing circuit in honeycomb lattice when its bits (from the least to the second most significant bit) are interpreted as directions to proceed at each vertex. (The most significant 1-bit is ignored).
8

%I #17 May 01 2015 05:36:53

%S 1,64,65,126,127,1056,1057,1090,1091,1156,1157,1288,1289,1518,1519,

%T 1552,1553,1782,1783,1914,1915,1980,1981,2014,2015,4368,4369,4642,

%U 4643,5188,5189,6006,6007,6280,6281,7098,7099,7644,7645,7918,7919,16962,16963,17028,17029,17160,17161,17542,17543,17544,17545,17674,17675,17938,17939

%N Numbers whose binary representation traces a nonselfcrossing circuit in honeycomb lattice when its bits (from the least to the second most significant bit) are interpreted as directions to proceed at each vertex. (The most significant 1-bit is ignored).

%C Numbers n such that when we start scanning bits in the binary expansion of n, from the least to the most significant end, and when we interpret each bit as to a direction which to turn at each vertex (e.g., 0 = left, 1 = right) when traversing the edges of honeycomb lattice, then, when we have consumed all except the most significant 1-bit (which is ignored), we have eventually returned to the same vertex where we started from and none of the other vertices have been visited twice.

%C Indexing starts from zero, because a(0) = 1 is a special case, indicating an empty path, which thus ends at the same vertex as where it started from.

%C If n is a member, then A054429(n) is also a member.

%H Antti Karttunen, <a href="/A255571/b255571.txt">Table of n, a(n) for n = 0..9300</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Honeycomb_lattice">Hexagonal lattice</a>

%e The examples given in A255570 occur also in this sequence, except that 380 ("101111100" in binary) is excluded from this sequence, because it visits twice the first vertex after the starting vertex.

%o (Scheme, with _Antti Karttunen_'s IntSeq-library)

%o (define A255571 (MATCHING-POS 0 1 isA255571?))

%o (define (isA255571? n) (let loop ((n n) (x 0) (y 0) (phase 0) (vv (list))) (cond ((= 1 n) (and (zero? x) (zero? y))) ((member (cons x y) vv) #f) (else (let* ((d (modulo n 2)) (newphase (modulo (+ phase d d -1) 6))) (loop (/ (- n d) 2) (+ x (x-delta newphase)) (+ y (y-delta newphase)) newphase (cons (cons x y) vv)))))))

%o (define (newphase p d) (modulo (+ p d d -1) 6))

%o (define (x-delta phase) (* (- (* 2 (floor->exact (/ phase 3))) 1) (- (modulo phase 3) 1)))

%o (define (y-delta phase) (* (- 1 (* 2 (floor->exact (/ phase 3)))) (floor->exact (/ (+ 1 (modulo phase 3)) 2))))

%Y Cf. A054429, A255561.

%Y Subsequence of A255570.

%K nonn,base

%O 0,2

%A _Antti Karttunen_, Apr 13 2015