%I #14 Apr 30 2015 21:43:09
%S 1,64,65,126,127,380,381,386,387,1056,1057,1090,1091,1156,1157,1274,
%T 1275,1286,1287,1288,1289,1518,1519,1552,1553,1782,1783,1784,1785,
%U 1796,1797,1914,1915,1980,1981,2014,2015,4096,4097,4158,4159,4160,4161,4222,4223,4348,4349,4368,4369,4598,4599,4600
%N Numbers whose binary representation traces a closed 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.
%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="/A255570/b255570.txt">Table of n, a(n) for n = 0..18484</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Honeycomb_lattice">Hexagonal lattice</a>
%e 64 ("1000000" in binary) is included, because when we take six turns to the left in the hexagonal lattice, we will reach the same vertex where we started from.
%e 65 ("1000001" in binary) is included, because if we take first turn to the right at some vertex, and then five turns to the left in succession, we also reach the same vertex we started from.
%e 126 ("1111110" in binary) is included, because if we take first turn to the left at some vertex, and then five turns to the right in succession, we also reach the same vertex we started from.
%e 127 ("1111111" in binary) is included, because if we take six turns to the right in the hexagonal lattice, we will reach the same vertex where we started from.
%e 380 ("101111100" in binary) is included, because it traces a path, where we first turn left from the starting vertex, then circumambulate a hexagon clockwise, after which we come back to the starting vertex. Note that the vertex next to the starting vertex is visited twice.
%o (Scheme, with _Antti Karttunen_'s IntSeq-library)
%o (define A255570 (MATCHING-POS 0 1 isA255570?))
%o (define (isA255570? n) (let loop ((n n) (x 0) (y 0) (phase 0)) (cond ((= 1 n) (and (zero? x) (zero? y))) (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))))))
%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. A014486, A054429.
%Y Subsequence: A255571.
%K nonn,base
%O 0,2
%A _Antti Karttunen_, Apr 13 2015