login
A007973
Number of permutations that are n-2 "block reversals" away from 12...n.
4
1, 3, 15, 55, 184, 648, 2111, 6352, 17337, 42878
OFFSET
2,2
FORMULA
a(n) = A300003(n,n-2).
PROG
(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
CROSSREFS
KEYWORD
nonn,more
AUTHOR
EXTENSIONS
a(9)-a(11) from Sean A. Irvine, Feb 22 2018
STATUS
approved