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.

A242519 Number of cyclic arrangements of S={1,2,...,n} such that the difference between any two neighbors is 2^k for some k=0,1,2,...

This page as a plain text file.
%I A242519 #31 Jan 06 2025 22:01:21
%S A242519 0,1,1,1,4,8,14,32,142,426,1204,3747,9374,26306,77700,219877,1169656,
%T A242519 4736264,17360564,69631372,242754286,891384309,3412857926,12836957200,
%U A242519 42721475348,152125749587,549831594988
%N A242519 Number of cyclic arrangements of S={1,2,...,n} such that the difference between any two neighbors is 2^k for some k=0,1,2,...
%C A242519 a(n)=NPC(n;S;P) is the count of all neighbor-property cycles for a specific set S of n elements and a specific pair-property P. Evaluating this sequence for n>=3 is equivalent to counting Hamiltonian cycles in a pair-property graph with n vertices and is often quite hard. For more details, see the link.
%H A242519 Hiroaki Yamanouchi, <a href="/A242519/b242519.txt">Table of n, a(n) for n = 1..27</a> (first 21 terms from Stanislav Sykora)
%H A242519 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.
%F A242519 For any S and any P, and for n>=3, NPC(n;S;P)<=A001710(n-1).
%e A242519 The four such cycles of length 5 are:
%e A242519 C_1={1,2,3,4,5}, C_2={1,2,4,3,5}, C_3={1,2,4,5,3}, C_4={1,3,2,4,5}.
%e A242519 The first and the last of the 426 such cycles of length 10 are:
%e A242519 C_1={1,2,3,4,5,6,7,8,10,9}, C_426={1,5,7,8,6,4,3,2,10,9}.
%t A242519 A242519[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
%t A242519 j1f[x_] := Join[{1}, x, {1}];
%t A242519 lpf[x_] := Length[Select[Abs[Differences[x]], ! MemberQ[t, #] &]];
%t A242519 t = Table[2^k, {k, 0, 10}];
%t A242519 Join[{0, 1}, Table[A242519[n], {n, 3, 10}]]
%t A242519 (* OR, a less simple, but more efficient implementation. *)
%t A242519 A242519[n_, perm_, remain_] := Module[{opt, lr, i, new},
%t A242519    If[remain == {},
%t A242519      If[MemberQ[t, Abs[First[perm] - Last[perm]]], ct++];
%t A242519      Return[ct],
%t A242519      opt = remain; lr = Length[remain];
%t A242519      For[i = 1, i <= lr, i++,
%t A242519       new = First[opt]; opt = Rest[opt];
%t A242519       If[! MemberQ[t, Abs[Last[perm] - new]], Continue[]];
%t A242519       A242519[n, Join[perm, {new}],
%t A242519        Complement[Range[2, n], perm, {new}]];
%t A242519       ];
%t A242519      Return[ct];
%t A242519      ];
%t A242519    ];
%t A242519 t = Table[2^k, {k, 0, 10}];
%t A242519 Join[{0, 1}, Table[ct = 0; A242519[n, {1}, Range[2, n]]/2, {n, 3, 12}]] (* _Robert Price_, Oct 22 2018 *)
%o A242519 (C++) // See Sykora link, Appendix B.
%Y A242519 Cf. A001710, A236602, A242520, A242521, A242522, A242523, A242524, A242525, A242526, A242527, A242528, A242529, A242530, A242531, A242532, A242533, A242534.
%K A242519 nonn,hard
%O A242519 1,5
%A A242519 _Stanislav Sykora_, May 27 2014
%E A242519 a(22)-a(27) from _Hiroaki Yamanouchi_, Aug 29 2014