login
Row sums of A371409: sums of the positions of right parentheses in the properly nested string of parentheses encoded by A063171(n).
2

%I #12 Mar 27 2024 16:32:13

%S 2,6,7,12,13,13,14,15,20,21,21,22,23,21,22,22,23,24,23,24,25,26,30,31,

%T 31,32,33,31,32,32,33,34,33,34,35,36,31,32,32,33,34,32,33,33,34,35,34,

%U 35,36,37,33,34,34,35,36,35,36,37,38,36,37,38,39,40,42,43,43,44,45,43

%N Row sums of A371409: sums of the positions of right parentheses in the properly nested string of parentheses encoded by A063171(n).

%C See A370220 and A371409 for more information.

%D Donald E. Knuth, The Art of Computer Programming, Vol. 4A: Combinatorial Algorithms, Part 1, Addison-Wesley, 2011, Section 7.2.1.6, pp. 440-444.

%H Paolo Xausa, <a href="/A371410/b371410.txt">Table of n, a(n) for n = 1..10000</a>

%t zlist[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Join[{1}, #] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];

%t Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 5}] (* _Paolo Xausa_, Mar 25 2024 *)

%t (* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)

%t zlist[m_] := Block[{z = 2*Range[m] - 1, j},

%t Reap[

%t While[True,

%t Sow[z];

%t If[z[[m-1]] < z[[m]] - 1,

%t z[[m]]--,

%t j = m - 1; z[[m]] = 2*m - 1;

%t While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];

%t If[j == 1,Break[]];

%t z[[j]]--]

%t ]][[2]][[1]]];

%t Join[{2}, Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 2, 5}]] (* _Paolo Xausa_, Mar 25 2024 *)

%Y Cf. A063171, A370220, A370290, A371409.

%K nonn

%O 1,1

%A _Paolo Xausa_, Mar 22 2024