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-4 of 4 results.

A300003 Triangle read by rows: T(n, k) = number of permutations that are k "block reversals" away from 12...n, for n >= 0, and (for n>0) 0 <= k <= n-1.

Original entry on oeis.org

1, 1, 1, 1, 1, 3, 2, 1, 6, 15, 2, 1, 10, 52, 55, 2, 1, 15, 129, 389, 184, 2, 1, 21, 266, 1563, 2539, 648, 2, 1, 28, 487, 4642, 16445, 16604, 2111, 2, 1, 36, 820, 11407, 69863, 169034, 105365, 6352, 2, 1, 45, 1297, 24600, 228613, 1016341, 1686534, 654030, 17337, 2
Offset: 0

Views

Author

Sean A. Irvine, Feb 22 2018

Keywords

Examples

			For n=3, the permutation 123 is reachable in 0 steps, 213 (reverse 12), 132 (reverse 23), 321 (reverse 123) are reachable in 1 step, and 231, 312 are reachable in 2 steps. Thus row 3 of the triangle is 1, 3, 2.
Triangle begins:
  1; (empty permutation, n = 0)
  1;
  1,   1;
  1,   3,   2;
  1,   6,  15,   2;
  1,  10,  52,  55,   2;
  1,  15, 129, 389, 184,   2;
  ...
The sum of row n is n! since each permutation of length n is accounted for in that row.
		

Crossrefs

Cf. A000217 (column 1), A007972 (column 2), A007975 (column 3), A007973 (T(n, n-2)), A007974 (T(n, n-3)).
Row sums give A000142.
Cf. A380576.

Programs

  • Python
    def row(n):
        perm = tuple(range(1, n+1)); reach = {perm}; frontier = {perm}
        out = [1] if n == 0 else []
        for k in range(n):
            r1 = set()
            out.append(len(frontier))
            while len(frontier) > 0:
                q = frontier.pop()
                for i in range(n):
                    for j in range(i+1, n+1):
                        qp = list(q)
                        qp[i:j] = qp[i:j][::-1]
                        qp = tuple(qp)
                        if qp not in reach:
                            reach.add(qp)
                            r1.add(qp)
            frontier = r1
        return out
    print([an for n in range(9) for an in row(n)]) # Michael S. Branicky, Jan 26 2023

Formula

Sum_{k>=1} k * T(n,k) = A380576(n). - Alois P. Heinz, Mar 26 2025

A007973 Number of permutations that are n-2 "block reversals" away from 12...n.

Original entry on oeis.org

1, 3, 15, 55, 184, 648, 2111, 6352, 17337, 42878, 102050, 239756, 562728
Offset: 2

Views

Author

Keywords

Crossrefs

Programs

  • Python
    def a(n):
        perm = tuple(range(1, n+1)); reach = {perm}; frontier = {perm}
        for k in range(n-2):
            r1 = set()
            while len(frontier) > 0:
                q = frontier.pop()
                for i in range(n):
                    for j in range(i+1, n+1):
                        qp = list(q)
                        qp[i:j] = qp[i:j][::-1]
                        qp = tuple(qp)
                        if qp not in reach:
                            reach.add(qp)
                            r1.add(qp)
            frontier = r1
        return len(frontier)
    print([a(n) for n in range(2, 10)]) # Michael S. Branicky, Jan 26 2023

Formula

a(n) = A300003(n,n-2).

Extensions

a(9)-a(11) from Sean A. Irvine, Feb 22 2018
a(12) from Thomas Baruchel, Mar 26 2025
a(13)-a(14) from Bert Dobbelaere, Apr 12 2025

A007974 Number of permutations that are n-3 "block reversals" away from 12...n.

Original entry on oeis.org

1, 6, 52, 389, 2539, 16604, 105365, 654030, 3900116, 22073230, 116855950, 567965207
Offset: 3

Views

Author

Keywords

Crossrefs

Programs

  • Python
    def a(n):
        perm = tuple(range(1, n+1)); reach = {perm}; frontier = {perm}
        for k in range(n-3):
            r1 = set()
            while len(frontier) > 0:
                q = frontier.pop()
                for i in range(n):
                    for j in range(i+1, n+1):
                        qp = list(q)
                        qp[i:j] = qp[i:j][::-1]
                        qp = tuple(qp)
                        if qp not in reach:
                            reach.add(qp)
                            r1.add(qp)
            frontier = r1
        return len(frontier)
    print([a(n) for n in range(3, 10)]) # Michael S. Branicky, Jan 26 2023

Formula

a(n) = A300003(n,n-3).

Extensions

a(9)-a(11) from Sean A. Irvine, Feb 22 2018
a(12) from Thomas Baruchel, Mar 26 2025
a(13)-a(14) from Bert Dobbelaere, Apr 12 2025

A007975 Number of permutations that are 3 "block reversals" away from 12...n.

Original entry on oeis.org

2, 55, 389, 1563, 4642, 11407, 24600, 48204, 87758, 150707, 246787, 388445, 591294, 874603, 1261822, 1781142, 2466090, 3356159, 4497473, 5943487, 7755722, 10004535, 12769924, 16142368, 20223702, 25128027, 30982655, 37929089, 46124038, 55740467, 66968682, 80017450, 95115154, 112510983, 132476157, 155305187, 181317170
Offset: 4

Views

Author

Keywords

Crossrefs

Column k=3 of A300003.

Formula

a(n) = A228397(n) - A228396(n). See C. Homberger links from A228396. - Martin Fuller, Mar 31 2025

Extensions

More terms from Sean A. Irvine, Feb 22 2018
a(34) onwards from Martin Fuller, Mar 31 2025
Showing 1-4 of 4 results.