A236602 Number of canonical Gray cycles of length 2n.
1, 1, 1, 6, 4, 22, 96, 1344, 672, 3448, 12114, 158424, 406312, 4579440, 37826256, 906545760, 362618304, 1784113248, 5576251408, 68998853808, 154939065862
Offset: 1
Examples
a(5) = 4 since there are only these 4 CGC's of length 10: {0 2 3 7 6 4 5 1 9 8} {0 2 6 4 5 7 3 1 9 8} {0 4 5 7 6 2 3 1 9 8} {0 4 6 2 3 7 5 1 9 8}
Links
- Stanislav Sykora, On Canonical Gray Cycles, Stan's Library, Vol.V, January 2014, DOI: 10.3247/SL5Math14.001.
Programs
-
Mathematica
A236602[n_] := Count[Map[lpf, Map[j0f, Permutations[Range[2 n - 1]]]], 0]/2; j0f[x_] := Join[{0}, x, {0}]; btf[x_] := Module[{i}, Table[DigitCount[BitXor[x[[i]], x[[i + 1]]], 2, 1], {i, Length[x] - 1}]]; lpf[x_] := Length[Select[btf[x], # != 1 &]]; Join[{1}, Table[A236602[n], {n, 2, 5}]] (* OR, a less simple, but more efficient implementation. *) A236602[n_, perm_, remain_] := Module[{opt, lr, i, new}, If[remain == {}, If[DigitCount[BitXor[First[perm], Last[perm]], 2, 1] == 1, ct++]; Return[ct], opt = remain; lr = Length[remain]; For[i = 1, i <= lr, i++, new = First[opt]; opt = Rest[opt]; If[DigitCount[BitXor[Last[perm], new], 2, 1] != 1, Continue[]]; A236602[n, Join[perm, {new}], Complement[Range[2 n - 1], perm, {new}]]; ]; Return[ct]; ]; ]; Join[{1}, Table[ct = 0; A236602[n, {0}, Range[2 n - 1]]/2, {n, 2, 8}] ](* Robert Price, Oct 25 2018 *)
Formula
a(2^(n-1)) = A066037(n).
a(n) = A350784(n)/2 for n >= 2. - Martin Ehrenstein, Feb 16 2022
Extensions
a(17)-a(18) from Fausto A. C. Cariboni, May 13 2017
a(19)-a(20) from Martin Ehrenstein, Feb 16 2022
a(21) from Martin Ehrenstein, Feb 21 2022
Comments