cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A242530 Number of cyclic arrangements of S={1,2,...,2n} such that the binary expansions of any two neighbors differ by one bit.

This page as a plain text file.
%I A242530 #18 Jan 06 2025 22:01:57
%S A242530 0,0,1,0,2,8,0,0,224,754,0,26256,0,0,22472304,0,90654576,277251016,0,
%T A242530 7852128780
%N A242530 Number of cyclic arrangements of S={1,2,...,2n} such that the binary expansions of any two neighbors differ by one bit.
%C A242530 Here, a(n)=NPC(2n;S;P) is the count of all neighbor-property cycles for a specific set S of 2n elements and a pair-property P. For more details, see the link and A242519.
%C A242530 In this case the property P is the Gray condition. The choice of the set S is important; when it is replaced by {0,1,2,...,2n-1}, the sequence changes completely and becomes A236602.
%H A242530 S. Sykora, <a href="http://dx.doi.org/10.3247/SL5Math14.002">On Neighbor-Property Cycles</a>, <a href="http://ebyte.it/library/Library.html#math">Stan's Library</a>, Volume V, 2014.
%e A242530 The two cycles for n=5 (cycle length 10) are:
%e A242530 C_1={1,3,7,5,4,6,2,10,8,9}, C_2={1,5,4,6,7,3,2,10,8,9}.
%t A242530 A242530[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, 2 n]]]], 0]/2;
%t A242530 j1f[x_] := Join[{1}, x, {1}];
%t A242530 btf[x_] := Module[{i},
%t A242530    Table[DigitCount[BitXor[x[[i]], x[[i + 1]]], 2, 1], {i,
%t A242530      Length[x] - 1}]];
%t A242530 lpf[x_] := Length[Select[btf[x], # != 1 &]];
%t A242530 Table[A242530[n], {n, 1, 5}]
%t A242530  (* OR, a less simple, but more efficient implementation. *)
%t A242530 A242530[n_, perm_, remain_] := Module[{opt, lr, i, new},
%t A242530    If[remain == {},
%t A242530      If[DigitCount[BitXor[First[perm], Last[perm]], 2, 1] == 1, ct++];
%t A242530      Return[ct],
%t A242530      opt = remain; lr = Length[remain];
%t A242530      For[i = 1, i <= lr, i++,
%t A242530       new = First[opt]; opt = Rest[opt];
%t A242530       If[DigitCount[BitXor[Last[perm], new], 2, 1] != 1, Continue[]];
%t A242530       A242530[n, Join[perm, {new}],
%t A242530        Complement[Range[2, 2 n], perm, {new}]];
%t A242530       ];
%t A242530      Return[ct];
%t A242530      ];
%t A242530    ];
%t A242530 Table[ct = 0; A242530[n, {1}, Range[2, 2 n]]/2, {n, 1, 10}] (* _Robert Price_, Oct 25 2018 *)
%o A242530 (C++) // See Sykora link.
%Y A242530 Cf. A236602, A242519, A242520, A242521, A242522, A242523, A242524, A242525, A242526, A242527, A242528, A242529, A242531, A242532, A242533, A242534.
%K A242530 nonn,hard,more
%O A242530 1,5
%A A242530 _Stanislav Sykora_, May 30 2014
%E A242530 a(16)-a(20) from _Fausto A. C. Cariboni_, May 10 2017, May 15 2017