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.

Showing 1-6 of 6 results.

A370290 Row sums of A370220.

Original entry on oeis.org

1, 4, 3, 9, 8, 8, 7, 6, 16, 15, 15, 14, 13, 15, 14, 14, 13, 12, 13, 12, 11, 10, 25, 24, 24, 23, 22, 24, 23, 23, 22, 21, 22, 21, 20, 19, 24, 23, 23, 22, 21, 23, 22, 22, 21, 20, 21, 20, 19, 18, 22, 21, 21, 20, 19, 20, 19, 18, 17, 19, 18, 17, 16, 15, 36, 35, 35, 34
Offset: 1

Views

Author

Paolo Xausa, Feb 14 2024

Keywords

Comments

See A370220 for more information.

Crossrefs

Cf. A370220.

Programs

  • Mathematica
    zsums[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Total[#]+1 &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];
    Flatten[Array[zsums, 6]]

A370222 Irregular triangle T(n,k) read by rows: row n gives the inversion table (see comments) of the permutation encoded by row n of A370221.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 2, 0, 1, 2, 0, 0, 1, 2, 1, 0, 1, 2, 2, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0
Offset: 1

Views

Author

Paolo Xausa, Feb 12 2024

Keywords

Comments

Knuth (2011) uses the inversion table c_1, c_2, ..., c_k (defined so that exactly c_k elements to the right of k are less than k) to encode the permutation given by row n of A370221.
This way c_1 = 0 and 0 <= c_(k+1) <= c_k + 1 for 1 <= k < m, where m >= 1 is half the length of the corresponding properly nested string of parentheses (see example).
The concatenation of terms in each row from row n = 23714 to 82498 (corresponding to strings of length 22, excluding the last one) gives the A000108(11) - 1 = 58785 terms of the finite sequence A239903.

Examples

			The following table lists c_k values for properly nested strings having lengths up to 8, along with d_k, z_k and p_k values from related combinatorial objects (see related sequences for more information). Cf. Knuth (2011), p. 442, Table 1.
.
      | Properly |          | A370219 | A370220 | A370221 |
      | Nested   | A063171  | d d d d | z z z z | p p p p | c c c c
    n | String   |   (n)    | 1 2 3 4 | 1 2 3 4 | 1 2 3 4 | 1 2 3 4
  ----+----------+----------+---------+---------+---------+---------
    1 | ()       | 10       | 1       | 1       | 1       | 0
    2 | ()()     | 1010     | 1 1     | 1 3     | 1 2     | 0 0
    3 | (())     | 1100     | 0 2     | 1 2     | 2 1     | 0 1
    4 | ()()()   | 101010   | 1 1 1   | 1 3 5   | 1 2 3   | 0 0 0
    5 | ()(())   | 101100   | 1 0 2   | 1 3 4   | 1 3 2   | 0 0 1
    6 | (())()   | 110010   | 0 2 1   | 1 2 5   | 2 1 3   | 0 1 0
    7 | (()())   | 110100   | 0 1 2   | 1 2 4   | 2 3 1   | 0 1 1
    8 | ((()))   | 111000   | 0 0 3   | 1 2 3   | 3 2 1   | 0 1 2
    9 | ()()()() | 10101010 | 1 1 1 1 | 1 3 5 7 | 1 2 3 4 | 0 0 0 0
   10 | ()()(()) | 10101100 | 1 1 0 2 | 1 3 5 6 | 1 2 4 3 | 0 0 0 1
   11 | ()(())() | 10110010 | 1 0 2 1 | 1 3 4 7 | 1 3 2 4 | 0 0 1 0
   12 | ()(()()) | 10110100 | 1 0 1 2 | 1 3 4 6 | 1 3 4 2 | 0 0 1 1
   13 | ()((())) | 10111000 | 1 0 0 3 | 1 3 4 5 | 1 4 3 2 | 0 0 1 2
   14 | (())()() | 11001010 | 0 2 1 1 | 1 2 5 7 | 2 1 3 4 | 0 1 0 0
   15 | (())(()) | 11001100 | 0 2 0 2 | 1 2 5 6 | 2 1 4 3 | 0 1 0 1
   16 | (()())() | 11010010 | 0 1 2 1 | 1 2 4 7 | 2 3 1 4 | 0 1 1 0
   17 | (()()()) | 11010100 | 0 1 1 2 | 1 2 4 6 | 2 3 4 1 | 0 1 1 1
   18 | (()(())) | 11011000 | 0 1 0 3 | 1 2 4 5 | 2 4 3 1 | 0 1 1 2
   19 | ((()))() | 11100010 | 0 0 3 1 | 1 2 3 7 | 3 2 1 4 | 0 1 2 0
   20 | ((())()) | 11100100 | 0 0 2 2 | 1 2 3 6 | 3 2 4 1 | 0 1 2 1
   21 | ((()())) | 11101000 | 0 0 1 3 | 1 2 3 5 | 3 4 2 1 | 0 1 2 2
   22 | (((()))) | 11110000 | 0 0 0 4 | 1 2 3 4 | 4 3 2 1 | 0 1 2 3
		

References

  • 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.

Crossrefs

Cf. A000108, A063171, A072643 (row lengths), A239903.
Cf. A370219, A370220, A370221, A370292 (row sums).

Programs

  • Mathematica
    clist[m_] := With[{r = 2*Range[2, m]-1}, Reverse[Map[Join[{0}, r-#] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] >= 0 &]]]];
    Array[Delete[clist[#], 0] &, 5]
    (* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)
    zlist[m_] := Block[{z = 2*Range[m] - 1, j},
        Reap[
        While[True,
            Sow[z];
            If[z[[m-1]] < z[[m]] - 1,
                z[[m]]--,
                j = m - 1; z[[m]] = 2*m - 1;
                While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];
                If[j == 1,Break[]];
                z[[j]]--]
        ]][[2]][[1]]];
    Join[{{0}}, Table[Delete[Map[2*Range[n] - 1 - # &, zlist[n]], 0], {n, 2, 5}]] (* Paolo Xausa, Mar 25 2024 *)

Formula

T(n,k) = 2*k - 1 - A370220(n,k).

A370221 Irregular triangle T(n,k) read by rows: row n lists the values encoding a permutation (see comments) related to the properly nested string of parentheses encoded by A063171(n).

Original entry on oeis.org

1, 1, 2, 2, 1, 1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 2, 1, 1, 2, 3, 4, 1, 2, 4, 3, 1, 3, 2, 4, 1, 3, 4, 2, 1, 4, 3, 2, 2, 1, 3, 4, 2, 1, 4, 3, 2, 3, 1, 4, 2, 3, 4, 1, 2, 4, 3, 1, 3, 2, 1, 4, 3, 2, 4, 1, 3, 4, 2, 1, 4, 3, 2, 1, 1, 2, 3, 4, 5, 1, 2, 3, 5, 4, 1, 2, 4, 3, 5
Offset: 1

Views

Author

Paolo Xausa, Feb 12 2024

Keywords

Comments

Knuth (2011) refers to these terms as p_k and defines them so that, in a properly nested string of parentheses, the k-th right parenthesis matches the p_k-th left parenthesis.
A370222 gives the corresponding values of a related inversion table.

Examples

			The following table lists p_k values for properly nested strings having lengths up to 8, along with d_k, z_k and c_k values from related combinatorial objects (see related sequences for more information). Cf. Knuth (2011), p. 442, Table 1.
.
      | Properly |          | A370219 | A370220 |         | A370222
      | Nested   | A063171  | d d d d | z z z z | p p p p | c c c c
    n | String   |   (n)    | 1 2 3 4 | 1 2 3 4 | 1 2 3 4 | 1 2 3 4
  ----+----------+----------+---------+---------+---------+---------
    1 | ()       | 10       | 1       | 1       | 1       | 0
    2 | ()()     | 1010     | 1 1     | 1 3     | 1 2     | 0 0
    3 | (())     | 1100     | 0 2     | 1 2     | 2 1     | 0 1
    4 | ()()()   | 101010   | 1 1 1   | 1 3 5   | 1 2 3   | 0 0 0
    5 | ()(())   | 101100   | 1 0 2   | 1 3 4   | 1 3 2   | 0 0 1
    6 | (())()   | 110010   | 0 2 1   | 1 2 5   | 2 1 3   | 0 1 0
    7 | (()())   | 110100   | 0 1 2   | 1 2 4   | 2 3 1   | 0 1 1
    8 | ((()))   | 111000   | 0 0 3   | 1 2 3   | 3 2 1   | 0 1 2
    9 | ()()()() | 10101010 | 1 1 1 1 | 1 3 5 7 | 1 2 3 4 | 0 0 0 0
   10 | ()()(()) | 10101100 | 1 1 0 2 | 1 3 5 6 | 1 2 4 3 | 0 0 0 1
   11 | ()(())() | 10110010 | 1 0 2 1 | 1 3 4 7 | 1 3 2 4 | 0 0 1 0
   12 | ()(()()) | 10110100 | 1 0 1 2 | 1 3 4 6 | 1 3 4 2 | 0 0 1 1
   13 | ()((())) | 10111000 | 1 0 0 3 | 1 3 4 5 | 1 4 3 2 | 0 0 1 2
   14 | (())()() | 11001010 | 0 2 1 1 | 1 2 5 7 | 2 1 3 4 | 0 1 0 0
   15 | (())(()) | 11001100 | 0 2 0 2 | 1 2 5 6 | 2 1 4 3 | 0 1 0 1
   16 | (()())() | 11010010 | 0 1 2 1 | 1 2 4 7 | 2 3 1 4 | 0 1 1 0
   17 | (()()()) | 11010100 | 0 1 1 2 | 1 2 4 6 | 2 3 4 1 | 0 1 1 1
   18 | (()(())) | 11011000 | 0 1 0 3 | 1 2 4 5 | 2 4 3 1 | 0 1 1 2
   19 | ((()))() | 11100010 | 0 0 3 1 | 1 2 3 7 | 3 2 1 4 | 0 1 2 0
   20 | ((())()) | 11100100 | 0 0 2 2 | 1 2 3 6 | 3 2 4 1 | 0 1 2 1
   21 | ((()())) | 11101000 | 0 0 1 3 | 1 2 3 5 | 3 4 2 1 | 0 1 2 2
   22 | (((()))) | 11110000 | 0 0 0 4 | 1 2 3 4 | 4 3 2 1 | 0 1 2 3
		

References

  • 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.

Crossrefs

Cf. A000108, A063171, A072643 (row lengths).
Cf. A370219, A370220, A370222, A370291 (row sums).

Programs

  • Mathematica
    slist[m_] := Reverse[Select[Permutations[PadLeft[Table[-1, m], 2*m, 1]], Min[Accumulate[#]] >= 0 &]];
    plist[s_] := Flatten[Reap[Module[{p, p0 = Flatten[Position[s, -1]], p1 = Flatten[Position[s, 1]], p1r}, p1r = p1; For[i = 1, i <= Length[p0], i++, p = Max[Select[p1r, # < p0[[i]] &]]; Sow[Position[p1, p]]; p1r = DeleteCases[p1r, p]]]][[2,1]]];
    Array[Delete[Map[plist, slist[#]], 0] &, 5]

A370219 Irregular triangle T(n,k) read by rows: row n lists run-length encoding d_k values (see comments) for the properly nested string of parentheses encoded by A063171(n).

Original entry on oeis.org

1, 1, 1, 0, 2, 1, 1, 1, 1, 0, 2, 0, 2, 1, 0, 1, 2, 0, 0, 3, 1, 1, 1, 1, 1, 1, 0, 2, 1, 0, 2, 1, 1, 0, 1, 2, 1, 0, 0, 3, 0, 2, 1, 1, 0, 2, 0, 2, 0, 1, 2, 1, 0, 1, 1, 2, 0, 1, 0, 3, 0, 0, 3, 1, 0, 0, 2, 2, 0, 0, 1, 3, 0, 0, 0, 4, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 0, 2, 1
Offset: 1

Views

Author

Paolo Xausa, Feb 12 2024

Keywords

Comments

As explained by Knuth (2011), a string of properly nested parentheses of length 2*m (for m >= 1) can be run-length encoded as ()d_1()d_2 ... ()d_m, where d_k are nonnegative integers such that d_1 + d_2 + ... + d_k <= k for 1 <= k < m and d_1 + d_2 + ... + d_m = m.

Examples

			The following table lists d_k values for properly nested strings having lengths up to 8, along with z_k, p_k and c_k values from related combinatorial objects (see related sequences for more information). Cf. Knuth (2011), p. 442, Table 1.
.
      | Properly |          |         | A370220 | A370221 | A370222
      | Nested   | A063171  | d d d d | z z z z | p p p p | c c c c
    n | String   |   (n)    | 1 2 3 4 | 1 2 3 4 | 1 2 3 4 | 1 2 3 4
  ----+----------+----------+---------+---------+---------+---------
    1 | ()       | 10       | 1       | 1       | 1       | 0
    2 | ()()     | 1010     | 1 1     | 1 3     | 1 2     | 0 0
    3 | (())     | 1100     | 0 2     | 1 2     | 2 1     | 0 1
    4 | ()()()   | 101010   | 1 1 1   | 1 3 5   | 1 2 3   | 0 0 0
    5 | ()(())   | 101100   | 1 0 2   | 1 3 4   | 1 3 2   | 0 0 1
    6 | (())()   | 110010   | 0 2 1   | 1 2 5   | 2 1 3   | 0 1 0
    7 | (()())   | 110100   | 0 1 2   | 1 2 4   | 2 3 1   | 0 1 1
    8 | ((()))   | 111000   | 0 0 3   | 1 2 3   | 3 2 1   | 0 1 2
    9 | ()()()() | 10101010 | 1 1 1 1 | 1 3 5 7 | 1 2 3 4 | 0 0 0 0
   10 | ()()(()) | 10101100 | 1 1 0 2 | 1 3 5 6 | 1 2 4 3 | 0 0 0 1
   11 | ()(())() | 10110010 | 1 0 2 1 | 1 3 4 7 | 1 3 2 4 | 0 0 1 0
   12 | ()(()()) | 10110100 | 1 0 1 2 | 1 3 4 6 | 1 3 4 2 | 0 0 1 1
   13 | ()((())) | 10111000 | 1 0 0 3 | 1 3 4 5 | 1 4 3 2 | 0 0 1 2
   14 | (())()() | 11001010 | 0 2 1 1 | 1 2 5 7 | 2 1 3 4 | 0 1 0 0
   15 | (())(()) | 11001100 | 0 2 0 2 | 1 2 5 6 | 2 1 4 3 | 0 1 0 1
   16 | (()())() | 11010010 | 0 1 2 1 | 1 2 4 7 | 2 3 1 4 | 0 1 1 0
   17 | (()()()) | 11010100 | 0 1 1 2 | 1 2 4 6 | 2 3 4 1 | 0 1 1 1
   18 | (()(())) | 11011000 | 0 1 0 3 | 1 2 4 5 | 2 4 3 1 | 0 1 1 2
   19 | ((()))() | 11100010 | 0 0 3 1 | 1 2 3 7 | 3 2 1 4 | 0 1 2 0
   20 | ((())()) | 11100100 | 0 0 2 2 | 1 2 3 6 | 3 2 4 1 | 0 1 2 1
   21 | ((()())) | 11101000 | 0 0 1 3 | 1 2 3 5 | 3 4 2 1 | 0 1 2 2
   22 | (((()))) | 11110000 | 0 0 0 4 | 1 2 3 4 | 4 3 2 1 | 0 1 2 3
		

References

  • 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.

Crossrefs

Cf. A000108, A063171, A072643 (row lengths and row sums).

Programs

  • Mathematica
    zlist[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Join[{1}, #] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];
    dlist[m_] := Map[Append[#, m - Total[#]] &, Map[Differences, zlist[m]] - 1];
    Array[Delete[dlist[#], 0] &, 5]
    (* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)
    zlist[m_] := Block[{z = 2*Range[m] - 1, j},
        Reap[
        While[True,
            Sow[z];
            If[z[[m-1]] < z[[m]] - 1,
                z[[m]]--,
                j = m - 1; z[[m]] = 2*m - 1;
                While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];
                If[j == 1,Break[]];
                z[[j]]--]
        ]][[2]][[1]]];
    dlist[m_] := Map[Append[#, m - Total[#]] &, Map[Differences, zlist[m]] - 1];
    Join[{{1}}, Array[Delete[dlist[#], 0] &, 4, 2]] (* Paolo Xausa, Mar 25 2024 *)

Formula

T(n,k) = A370220(n,k+1) - A370220(n,k) - 1, for 1 <= k < A072643(n).

A371409 Irregular triangle T(n,k) read by rows: row n lists the positions of right parentheses in the properly nested string of parentheses encoded by A063171(n).

Original entry on oeis.org

2, 2, 4, 3, 4, 2, 4, 6, 2, 5, 6, 3, 4, 6, 3, 5, 6, 4, 5, 6, 2, 4, 6, 8, 2, 4, 7, 8, 2, 5, 6, 8, 2, 5, 7, 8, 2, 6, 7, 8, 3, 4, 6, 8, 3, 4, 7, 8, 3, 5, 6, 8, 3, 5, 7, 8, 3, 6, 7, 8, 4, 5, 6, 8, 4, 5, 7, 8, 4, 6, 7, 8, 5, 6, 7, 8, 2, 4, 6, 8, 10, 2, 4, 6, 9, 10, 2, 4, 7, 8, 10
Offset: 1

Views

Author

Paolo Xausa, Mar 22 2024

Keywords

Comments

See A370220 for the positions of left parentheses.

Examples

			The following table lists the positions of right parentheses for properly nested strings having lengths up to 8, along with the positions of left parentheses.
.
      | Properly |          | Pos. of right | Pos. of left
      | Nested   | A063171  | parentheses   | parentheses
    n | String   |   (n)    | (this seq.)   | (A370220)
  ----+----------+----------+---------------+---------------
    1 | ()       | 10       | 2             | 1
    2 | ()()     | 1010     | 2 4           | 1 3
    3 | (())     | 1100     | 3 4           | 1 2
    4 | ()()()   | 101010   | 2 4 6         | 1 3 5
    5 | ()(())   | 101100   | 2 5 6         | 1 3 4
    6 | (())()   | 110010   | 3 4 6         | 1 2 5
    7 | (()())   | 110100   | 3 5 6         | 1 2 4
    8 | ((()))   | 111000   | 4 5 6         | 1 2 3
    9 | ()()()() | 10101010 | 2 4 6 8       | 1 3 5 7
   10 | ()()(()) | 10101100 | 2 4 7 8       | 1 3 5 6
   11 | ()(())() | 10110010 | 2 5 6 8       | 1 3 4 7
   12 | ()(()()) | 10110100 | 2 5 7 8       | 1 3 4 6
   13 | ()((())) | 10111000 | 2 6 7 8       | 1 3 4 5
   14 | (())()() | 11001010 | 3 4 6 8       | 1 2 5 7
   15 | (())(()) | 11001100 | 3 4 7 8       | 1 2 5 6
   16 | (()())() | 11010010 | 3 5 6 8       | 1 2 4 7
   17 | (()()()) | 11010100 | 3 5 7 8       | 1 2 4 6
   18 | (()(())) | 11011000 | 3 6 7 8       | 1 2 4 5
   19 | ((()))() | 11100010 | 4 5 6 8       | 1 2 3 7
   20 | ((())()) | 11100100 | 4 5 7 8       | 1 2 3 6
   21 | ((()())) | 11101000 | 4 6 7 8       | 1 2 3 5
   22 | (((()))) | 11110000 | 5 6 7 8       | 1 2 3 4
		

References

  • 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.

Crossrefs

Cf. A063171, A370220, A072643 (row lengths), A371410 (row sums).

Programs

  • Mathematica
    zlist[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Join[{1}, #] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];
    Table[Delete[Map[Complement[Range[2*m], #] &, zlist[m]], 0], {m, 5}] (* Paolo Xausa, Mar 27 2024 *)
    (* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)
    zlist[m_] := Block[{z = 2*Range[m] - 1, j},
        Reap[
        While[True,
            Sow[z];
            If[z[[m-1]] < z[[m]] - 1,
                z[[m]]--,
                j = m - 1; z[[m]] = 2*m - 1;
                While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];
                If[j == 1,Break[]];
                z[[j]]--]
        ]][[2]][[1]]];
    Join[{{2}}, Table[Delete[Map[Complement[Range[2*m], #] &, zlist[m]], 0], {m, 2, 5}]] (* Paolo Xausa, Mar 27 2024 *)

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

Original entry on oeis.org

2, 6, 7, 12, 13, 13, 14, 15, 20, 21, 21, 22, 23, 21, 22, 22, 23, 24, 23, 24, 25, 26, 30, 31, 31, 32, 33, 31, 32, 32, 33, 34, 33, 34, 35, 36, 31, 32, 32, 33, 34, 32, 33, 33, 34, 35, 34, 35, 36, 37, 33, 34, 34, 35, 36, 35, 36, 37, 38, 36, 37, 38, 39, 40, 42, 43, 43, 44, 45, 43
Offset: 1

Views

Author

Paolo Xausa, Mar 22 2024

Keywords

Comments

See A370220 and A371409 for more information.

References

  • 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.

Crossrefs

Programs

  • Mathematica
    zlist[m_] := With[{r = 2*Range[2, m]}, Reverse[Map[Join[{1}, #] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] > 0 &]]]];
    Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 5}] (* Paolo Xausa, Mar 25 2024 *)
    (* 2nd program: uses Algorithm Z from Knuth's TAOCP section 7.2.1.6, exercise 2 *)
    zlist[m_] := Block[{z = 2*Range[m] - 1, j},
        Reap[
        While[True,
            Sow[z];
            If[z[[m-1]] < z[[m]] - 1,
                z[[m]]--,
                j = m - 1; z[[m]] = 2*m - 1;
                While[j > 1 && z[[j-1]] == z[[j]] - 1, z[[j]] = 2*j - 1; j--];
                If[j == 1,Break[]];
                z[[j]]--]
        ]][[2]][[1]]];
    Join[{2}, Table[Delete[Map[Total[Complement[Range[2*m], #]] &, zlist[m]], 0], {m, 2, 5}]] (* Paolo Xausa, Mar 25 2024 *)
Showing 1-6 of 6 results.