OFFSET
0,2
COMMENTS
a(n) is the number of nested pairs of Schroeder paths of length 2*n.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..661
EXAMPLE
The a(2) = 20 pairs of Schroeder paths are:
. __
____ __/\ /\__ /\/\ / \
____ ____ ____ ____ ____
.
/\ __ /\
/ \ __/\ /\/\ / \ / \
____ __/\ __/\ __/\ __/\
.
__ /\
/\__ /\/\ / \ / \ /\/\
/\__ /\__ /\__ /\__ /\/\
.
__ /\ __ /\ /\
/ \ / \ /__\ /__\ //\\
/\/\ /\/\ / \ / \ / \
PROG
(Python)
from collections import defaultdict
def a_gen(n): #generator of terms a(0) to a(n)
D = {(0, 0):1}
for k in range(2*n+2):
D2 = defaultdict(int)
for i, j in D:
d = D[(i, j)]
mi, mj = (i-k)%2, (j-k)%2
for a in range(-mi, mi+1):
for b in range(-mj, mj+1):
if 0 <= i+a <= j+b <= 2*n-k+1:
D2[(i+a, j+b)] += d
D = D2
if k%2==1:
yield D[(0, 0)]
CROSSREFS
KEYWORD
nonn
AUTHOR
Ludovic Schwob, Dec 14 2024
STATUS
approved
