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.

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