login
A007974
Number of permutations that are n-3 "block reversals" away from 12...n.
4
1, 6, 52, 389, 2539, 16604, 105365, 654030, 3900116
OFFSET
3,2
FORMULA
a(n) = A300003(n,n-3).
PROG
(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
CROSSREFS
KEYWORD
nonn,more
AUTHOR
EXTENSIONS
a(9)-a(11) from Sean A. Irvine, Feb 22 2018
STATUS
approved