Skip to content

SeparablePermutations ​

The permutations of {1,…,n}\{1, …, n\} avoiding the patterns 24132413 and 31423142, as a lazy indexed family.

SeparablePermutations(n)the permutations of {1,…,n}\{1, …, n\} built up by direct and skew sums.
Typed signatures
TypePackageApplies
(integer<0..>) -> indexed_collection<permutation>combinatoricsalways

Domain: Collections

Details
  • A lazy indexed collection; the count is the large Schröder numbers, A006318 — 1,2,6,22,90,…1, 2, 6, 22, 90, …
  • Each element is the one-line word; AtAt enumerates all n!n! permutations in lexicographic order and indexes into those avoiding 24132413 and 31423142 — there is no closed-form unrank of the permutation itself.
  • Separable permutations are exactly those avoiding every non-trivial SimplePermutations pattern beyond length 22 — every one decomposes recursively as a direct or skew sum.

Definition

Epsil, as the implementation runs it.

count(_n)

Apply((schroder: list<integer>) => Apply(
                                          (prefix: list<integer>) => Apply((filled: integer) => (1 if _n == 0 else schroder[_n]) if filled == 0 else 0 if Fold(Function(spc_ ||
                                                                                                                                                                        Fold(Function(spb_ ||
                                                                                                                                                                                      Fold(Function(spa_ ||
                                                                                                                                                                                                    prefix[spc] < prefix[spa] &&
                                                                                                                                                                                                    prefix[spa] < prefix[filled] &&
                                                                                                                                                                                                    prefix[filled] < prefix[spb] ||
                                                                                                                                                                                                    prefix[spb] < prefix[filled] &&
                                                                                                                                                                                                    prefix[filled] < prefix[spa] &&
                                                                                                                                                                                                    prefix[spa] < prefix[spc], spa_, spa), False, Range(1, spb - 1, 1)), spb_, spb), False, Range(1, spc - 1, 1)), spc_, spc), False, Range(1, filled - 1, 1)) else Apply(
                                                                                                                                                                                                                                  (smin: list<integer>) => Apply(
                                                                                                                                                                                                                                                                  (smax: list<integer>) => Apply((sw: integer) => Apply(
                                                                                                                                                                                                                                                                                                                         (stable: list<integer>) => (1 if _n == 0 else schroder[_n]) if 0 == filled else (1 if _n == 1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                         stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                2 *
                                                                                                                                                                                                                                                                                                                                                                                                                ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                 0 +
                                                                                                                                                                                                                                                                                                                                                                                                                 (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                1] +
                                                                                                                                                                                                                                                                                                                                                                                                         stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                2 *
                                                                                                                                                                                                                                                                                                                                                                                                                ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                 0 +
                                                                                                                                                                                                                                                                                                                                                                                                                 (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                1] if 0 < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                             filled - 0 <=
                                                                                                                                                                                                                                                                                                                                                                                                             _n &&
                                                                                                                                                                                                                                                                                                                                                                                                             1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                             1 <=
                                                                                                                                                                                                                                                                                                                                                                                                             _n &&
                                                                                                                                                                                                                                                                                                                                                                                                             smin[0 + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                             1 &&
                                                                                                                                                                                                                                                                                                                                                                                                             smax[0 + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                             1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                             1 else 0,
                                                                                                                                                                                                                                                                                                                         Fold(
                                                                                                                                                                                                                                                                                                                               Function(Join(
                                                                                                                                                                                                                                                                                                                                              st_t,
                                                                                                                                                                                                                                                                                                                                              Fold(Function(ReplaceAt(
                                                                                                                                                                                                                                                                                                                                                                       st_row,
                                                                                                                                                                                                                                                                                                                                                                       st_c + 1,
                                                                                                                                                                                                                                                                                                                                                                       Apply((stq: integer) => Apply((stj: integer) => Apply((stl: integer) => (Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                       (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stl + sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                       Apply((sr_init: list<integer>) => Fold((sr: list<integer>, sc) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (sr_next: list<integer>) => sr_next,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srm == stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             stl + sc -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1 else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc])),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ), sr_init, Range(1, filled - stj, 1)), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ) if st_c % 2 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                         0 else Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ss -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Apply((sr_init: list<integer>) => Fold((sr: list<integer>, sc) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               (sr_next: list<integer>) => sr_next,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            srm ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            sc else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc])),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ), sr_init, Range(1, filled - stj, 1)), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    )) if stj < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         filled - stj <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_s &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         smin[stj + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         smax[stj + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1 else 0, stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (_n + 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  1), (stq -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (_n + 1)) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     (_n + 1)), (st_c -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_c % 2) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        2),
                                                                                                                                                                                                                                                                                                                                                                     ), st_row, st_c), Map(Function(0, st_z), Range(0, sw - 1, 1)), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                            ), st_t, st_s),
                                                                                                                                                                                                                                                                                                                               Fold(
                                                                                                                                                                                                                                                                                                                                     Function(ReplaceAt(st_row, st_c + 1, 0), st_row, st_c),
                                                                                                                                                                                                                                                                                                                                     Map(Function(0, st_z), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                     Range(0, sw - 1, 1),
                                                                                                                                                                                                                                                                                                                                   ),
                                                                                                                                                                                                                                                                                                                               Range(1, _n + 1 -
                                                                                                                                                                                                                                                                                                                                        1, 1),
                                                                                                                                                                                                                                                                                                                             ),
                                                                                                                                                                                                                                                                                                                       ), 2 * filled * (_n + 1)),
                                                                                                                                                                                                                                                                  Fold(
                                                                                                                                                                                                                                                                        Function(ReplaceAt(smj_l, smj - 1 +
                                                                                                                                                                                                                                                                                                  1, Fold(Function(Max(sme, prefix[smq]), sme, smq), 0, Range(smj, filled, 1))), smj_l, smj),
                                                                                                                                                                                                                                                                        Map(Function(0, smj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                                                        Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                                                      ),
                                                                                                                                                                                                                                                                ),
                                                                                                                                                                                                                                  Fold(
                                                                                                                                                                                                                                        Function(ReplaceAt(snj_l, snj - 1 +
                                                                                                                                                                                                                                                                  1, Fold(Function(Min(sne, prefix[snq]), sne, snq), _n + 1, Range(snj, filled, 1))), snj_l, snj),
                                                                                                                                                                                                                                        Map(Function(0, snj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                        Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                      ),
                                                                                                                                                                                                                                ), 0),
                                          Map(
                                               Function(0, lr_y),
                                               Range(1, _n, 1),
                                             ),
                                        ), _tables)

unrank(_n, _r)

Apply((schroder: list<integer>) => Take(Fold(Function(Apply(
                                                             (lr_chosen: list<integer>) => ReplaceAt(ReplaceAt(
                                                                                                                ReplaceAt(lr_s, lr_j, lr_chosen[2]),
                                                                                                                _n + 1,
                                                                                                                lr_chosen[1],
                                                                                                              ), _n + 1 + lr_chosen[2], lr_j),
                                                             Fold(Function(lr_pick if lr_pick[2] != 0 else lr_pick if lr_s[_n + 1 + lr_v] !=
                                                                                                                      0 else Apply(
                                                                                                                                   (lr_c: integer) => [lr_pick[1], lr_v] if lr_pick[1] < lr_c else [lr_pick[1] - lr_c, 0],
                                                                                                                                   Apply((prefix: list<integer>) => Apply((filled: integer) => (1 if _n == 0 else schroder[_n]) if filled == 0 else 0 if Fold(Function(spc_ ||
                                                                                                                                                                                                                                                                       Fold(Function(spb_ ||
                                                                                                                                                                                                                                                                                     Fold(Function(spa_ ||
                                                                                                                                                                                                                                                                                                   prefix[spc] < prefix[spa] &&
                                                                                                                                                                                                                                                                                                   prefix[spa] < prefix[filled] &&
                                                                                                                                                                                                                                                                                                   prefix[filled] < prefix[spb] ||
                                                                                                                                                                                                                                                                                                   prefix[spb] < prefix[filled] &&
                                                                                                                                                                                                                                                                                                   prefix[filled] < prefix[spa] &&
                                                                                                                                                                                                                                                                                                   prefix[spa] < prefix[spc], spa_, spa), False, Range(1, spb - 1, 1)), spb_, spb), False, Range(1, spc - 1, 1)), spc_, spc), False, Range(1, filled - 1, 1)) else Apply(
                                                                                                                                                                                                                                                                                                                                 (smin: list<integer>) => Apply(
                                                                                                                                                                                                                                                                                                                                                                 (smax: list<integer>) => Apply((sw: integer) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                        (stable: list<integer>) => (1 if _n == 0 else schroder[_n]) if 0 == filled else (1 if _n == 1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1] if 0 < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            filled - 0 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            smin[0 + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            smax[0 + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 else 0,
                                                                                                                                                                                                                                                                                                                                                                                                                        Fold(Function(Join(
                                                                                                                                                                                                                                                                                                                                                                                                                                            st_t,
                                                                                                                                                                                                                                                                                                                                                                                                                                            Fold(Function(ReplaceAt(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                     st_row,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                     st_c + 1,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Apply((stq: integer) => Apply((stj: integer) => Apply((stl: integer) => (Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stl + sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Apply((sr_init: list<integer>) => Fold(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (sr: list<integer>, sc) => Apply((sr_next: list<integer>) => sr_next, sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srm == stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                stl + sc -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc]))),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             sr_init,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Range(1, filled - stj, 1),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ) if st_c % 2 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       0 else Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ss -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Apply((sr_init: list<integer>) => Fold((sr: list<integer>, sc) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (sr_next: list<integer>) => sr_next,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          srm ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          sc else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc])),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ), sr_init, Range(1, filled - stj, 1)), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  )) if stj < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       filled - stj <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_s &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       smin[stj + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       smax[stj + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1 else 0, stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (_n + 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1), (stq -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (_n + 1)) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   (_n + 1)), (st_c -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_c % 2) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      2),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ), st_row, st_c), Map(Function(0, st_z), Range(0, sw - 1, 1)), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                          ), st_t, st_s), Fold(
                                                                                                                                                                                                                                                                                                                                                                                                                                                               Function(ReplaceAt(st_row, st_c + 1, 0), st_row, st_c),
                                                                                                                                                                                                                                                                                                                                                                                                                                                               Map(Function(0, st_z), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                               Range(0, sw - 1, 1),
                                                                                                                                                                                                                                                                                                                                                                                                                                                             ), Range(1, _n + 1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                      ), 2 * filled * (_n + 1)),
                                                                                                                                                                                                                                                                                                                                                                 Fold(
                                                                                                                                                                                                                                                                                                                                                                       Function(ReplaceAt(smj_l, smj - 1 +
                                                                                                                                                                                                                                                                                                                                                                                                 1, Fold(Function(Max(sme, prefix[smq]), sme, smq), 0, Range(smj, filled, 1))), smj_l, smj),
                                                                                                                                                                                                                                                                                                                                                                       Map(Function(0, smj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                                                                                                                                                       Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                                                                                                                                                     ),
                                                                                                                                                                                                                                                                                                                                                               ),
                                                                                                                                                                                                                                                                                                                                 Fold(
                                                                                                                                                                                                                                                                                                                                       Function(ReplaceAt(snj_l, snj - 1 +
                                                                                                                                                                                                                                                                                                                                                                 1, Fold(Function(Min(sne, prefix[snq]), sne, snq), _n + 1, Range(snj, filled, 1))), snj_l, snj),
                                                                                                                                                                                                                                                                                                                                       Map(Function(0, snj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                                                                                                                       Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                                                                                                                     ),
                                                                                                                                                                                                                                                                                                                               ), lr_j), ReplaceAt(lr_s, lr_j, lr_v)),
                                                                                                                                 ), lr_pick, lr_v), [lr_s[_n + 1], 0], Range(1, _n, 1)),
                                                           ), lr_s, lr_j), Join(
                                                                                Map(
                                                                                     Function(0, lr_y),
                                                                                     Range(1, _n, 1),
                                                                                   ),
                                                                                [_r],
                                                                                Map(
                                                                                     Function(0, lr_y2),
                                                                                     Range(1, _n, 1),
                                                                                   ),
                                                                              ), Range(1, _n, 1)), _n), _tables)

rank(_n, _x)

Apply((schroder: list<integer>) => Apply(
                                          (lr_where: list<integer>) => Fold(Function(lr_r +
                                                                                     Apply(
                                                                                            (lr_base: list<integer>) => Fold(Function(lr_r2 +
                                                                                                                                      (Apply((prefix: list<integer>) => Apply((filled: integer) => (1 if _n == 0 else schroder[_n]) if filled == 0 else 0 if Fold(Function(spc_ ||
                                                                                                                                                                                                                                                                           Fold(Function(spb_ ||
                                                                                                                                                                                                                                                                                         Fold(Function(spa_ ||
                                                                                                                                                                                                                                                                                                       prefix[spc] < prefix[spa] &&
                                                                                                                                                                                                                                                                                                       prefix[spa] < prefix[filled] &&
                                                                                                                                                                                                                                                                                                       prefix[filled] < prefix[spb] ||
                                                                                                                                                                                                                                                                                                       prefix[spb] < prefix[filled] &&
                                                                                                                                                                                                                                                                                                       prefix[filled] < prefix[spa] &&
                                                                                                                                                                                                                                                                                                       prefix[spa] < prefix[spc], spa_, spa), False, Range(1, spb - 1, 1)), spb_, spb), False, Range(1, spc - 1, 1)), spc_, spc), False, Range(1, filled - 1, 1)) else Apply(
                                                                                                                                                                                                                                                                                                                                     (smin: list<integer>) => Apply(
                                                                                                                                                                                                                                                                                                                                                                     (smax: list<integer>) => Apply((sw: integer) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                            (stable: list<integer>) => (1 if _n == 0 else schroder[_n]) if 0 == filled else (1 if _n == 1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stable[_n * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (1 - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1] if 0 < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                filled - 0 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                smin[0 + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                smax[0 + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 + _n -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1 else 0,
                                                                                                                                                                                                                                                                                                                                                                                                                            Fold(Function(Join(
                                                                                                                                                                                                                                                                                                                                                                                                                                                st_t,
                                                                                                                                                                                                                                                                                                                                                                                                                                                Fold(Function(ReplaceAt(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_row,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_c + 1,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Apply((stq: integer) => Apply((stj: integer) => Apply((stl: integer) => (Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (stl + sc0 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stl + sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stl + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Apply((sr_init: list<integer>) => Fold(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 (sr: list<integer>, sc) => Apply((sr_next: list<integer>) => sr_next, sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srm == stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    stl + sc -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    1 else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc]))),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 sr_init,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Range(1, filled - stj, 1),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ) if st_c % 2 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           0 else Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (sc0: integer) => (((1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  0 else schroder[st_s - sc0]) if stj + sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 filled else (1 if st_s - sc0 ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1 else 0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1] +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       st_t[(st_s - sc0) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (stj + sc0) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (stl - 1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (2 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1] if stj + sc0 <
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           filled -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (stj + sc0) <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           st_s - sc0 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           smin[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           smax[stj + sc0 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (st_s - sc0) -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 else 0) if sc0 < st_s else 0) if sc0 > 0 else Fold(Function(sum_ss +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        st_t[ss * sw +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             2 *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ((_n + 1) *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ss -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1)) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (1 - 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1] *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (1 if st_s - ss ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              0 else schroder[st_s - ss]), sum_ss, ss), 0, Range(filled - stj +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                1, st_s - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Apply((sr_init: list<integer>) => Fold((sr: list<integer>, sc) => Apply(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 (sr_next: list<integer>) => sr_next,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 sr if sr[1] != 0 else Apply((srm: integer) => Apply((srx: integer) => [sc if srx ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1 &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              srm ==
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1 +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              sc else 0, srm, srx], Max(sr[3], prefix[stj + sc])), Min(sr[2], prefix[stj + sc])),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ), sr_init, Range(1, filled - stj, 1)), [0, _n + 1, 0])[1],
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      )) if stj < filled &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           filled - stj <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           st_s &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           _n &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           smin[stj + 1] >=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl &&
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           smax[stj + 1] <=
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           stl + st_s -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1 else 0, stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (_n + 1) +
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    1), (stq -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stq %
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (_n + 1)) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (_n + 1)), (st_c -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           st_c % 2) /
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ), st_row, st_c), Map(Function(0, st_z), Range(0, sw - 1, 1)), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                              ), st_t, st_s), Fold(
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Function(ReplaceAt(st_row, st_c + 1, 0), st_row, st_c),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Map(Function(0, st_z), Range(0, sw - 1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Range(0, sw - 1, 1),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ), Range(1, _n + 1 -
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            1, 1)),
                                                                                                                                                                                                                                                                                                                                                                                                                          ), 2 * filled * (_n + 1)),
                                                                                                                                                                                                                                                                                                                                                                     Fold(
                                                                                                                                                                                                                                                                                                                                                                           Function(ReplaceAt(smj_l, smj - 1 +
                                                                                                                                                                                                                                                                                                                                                                                                     1, Fold(Function(Max(sme, prefix[smq]), sme, smq), 0, Range(smj, filled, 1))), smj_l, smj),
                                                                                                                                                                                                                                                                                                                                                                           Map(Function(0, smj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                                                                                                                                                           Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                                                                                                                                                         ),
                                                                                                                                                                                                                                                                                                                                                                   ),
                                                                                                                                                                                                                                                                                                                                     Fold(
                                                                                                                                                                                                                                                                                                                                           Function(ReplaceAt(snj_l, snj - 1 +
                                                                                                                                                                                                                                                                                                                                                                     1, Fold(Function(Min(sne, prefix[snq]), sne, snq), _n + 1, Range(snj, filled, 1))), snj_l, snj),
                                                                                                                                                                                                                                                                                                                                           Map(Function(0, snj_z), Range(1, Max(filled, 1), 1)),
                                                                                                                                                                                                                                                                                                                                           Range(1, Max(filled, 1), 1),
                                                                                                                                                                                                                                                                                                                                         ),
                                                                                                                                                                                                                                                                                                                                   ), lr_j), ReplaceAt(lr_base, lr_j, lr_v)) if lr_where[lr_v] > lr_j else 0), lr_r2, lr_v), 0, Range(1, _x[lr_j] - 1, 1)),
                                                                                            Map(
                                                                                                 Function(_x[lr_q] if lr_q < lr_j else 0, lr_q),
                                                                                                 Range(1, _n, 1),
                                                                                               ),
                                                                                          ), lr_r, lr_j), 0, Range(1, _n, 1)),
                                          Fold(
                                                Function(ReplaceAt(
                                                                    lr_at,
                                                                    _x[lr_p],
                                                                    lr_p,
                                                                  ), lr_at, lr_p),
                                                Map(
                                                     Function(0, lr_y3),
                                                     Range(1, _n, 1),
                                                   ),
                                                Range(1, _n, 1),
                                              ),
                                        ), _tables)

valid(_n, _x)

(!Fold(
        Function(sd_ || Fold(Function(sxc_ || Fold(
                                                    Function(sxb_ || Fold(
                                                                           Function(sxa_ ||
                                                                                    _x[sxc] < _x[sxa] &&
                                                                                    _x[sxa] < _x[sd] &&
                                                                                    _x[sd] < _x[sxb] ||
                                                                                    _x[sxb] < _x[sd] &&
                                                                                    _x[sd] < _x[sxa] &&
                                                                                    _x[sxa] < _x[sxc], sxa_, sxa),
                                                                           False,
                                                                           Range(
                                                                                  1,
                                                                                  sxb - 1,
                                                                                  1,
                                                                                ),
                                                                         ), sxb_, sxb),
                                                    False,
                                                    Range(1, sxc - 1, 1),
                                                  ), sxc_, sxc), False, Range(
                                                                              1,
                                                                              sd -
                                                                              1,
                                                                              1,
                                                                            )), sd_, sd),
        False,
        Range(1, _n, 1),
      ) if Fold(Function(
                         (ReplaceAt(lr_d_seen, _x[lr_d_j], 1) if lr_d_seen[_x[lr_d_j]] ==
                                                                 0 else ReplaceAt(
                                                                                  lr_d_seen,
                                                                                  _n + 1,
                                                                                  1,
                                                                                )) if 1 <= _x[lr_d_j] &&
                                                                                     _x[lr_d_j] <= _n else ReplaceAt(lr_d_seen, _n + 1, 1),
                         lr_d_seen,
                         lr_d_j,
                       ), Map(Function(0, lr_d_z), Range(1, _n + 1, 1)), Range(1, _n, 1))[_n + 1] ==
          0 else False) if Length(_x) == _n else False

tables(_n)

Apply((sq_init: list<integer>) => Fold(
                                        (sq: list<integer>, sk) => Apply(
                                                                          (sq_next: list<integer>) => sq_next,
                                                                          Append(
                                                                                  sq,
                                                                                  sq[sk] +
                                                                                  Fold(
                                                                                        Function(sum_si +
                                                                                                 sq[si + 1] *
                                                                                                 sq[sk - si], sum_si, si),
                                                                                        0,
                                                                                        Range(0, sk - 1, 1),
                                                                                      ),
                                                                                ),
                                                                        ),
                                        sq_init,
                                        Range(1, _n - 1, 1),
                                      ), [1])

Statistics

On Permutation, called as CombinatorialStat(x, "Name").

Maps

Into and out of Permutation, called as CombinatorialMap(x, "Name"). Properties are the laws we state and what FindStat records.

From Permutation

  • BinarySearchTreePermutation → BinaryTreesurjectionSurjectionGraded mapMp00072The tree built by inserting σ(1), σ(2), ... into an empty binary search tree.
  • BinarySearchTreeParentArrayPermutation → BinaryTreeParentArrayThe binary search tree of σ as its parent array: entry v is the value v is inserted under, 0 for the root.
  • CactusEvacuationPermutation → PermutationinvolutionBijectionGraded mapInvolutionMp00126The permutation with the same insertion tableau and the evacuation of the recording tableau.
  • ComplementPermutation → PermutationinvolutionBijectionGraded mapInvolutionMp00069Each entry replaced by n + 1 minus itself.
  • ConjugacyClassRepresentativePermutation → PermutationidempotentThe canonical permutation with the same cycle type.
  • ConjugateAfterCycleTypePermutation → IntegerPartitionThe conjugate partition of the cycle type.
  • ConnectivityWordPermutation → BinaryWordsurjectionSurjectionGraded mapMp00114Letter i is 1 when the first i entries are all smaller than the rest: the connectivity set as a binary word.
  • CycleAsOneLineNotationPermutation → PermutationGraded mapMp00090The cycles, each written from its least point and in order of those points, read as one word.
  • CycleDecompositionPermutation → CycleDecompositioninverseA permutation in cycle notation, fixed points kept: each cycle from its least point, cycles in order of those points.
  • CyclePartitionPermutation → SetPartitionsurjectionSurjectionGraded mapMp00151The orbits, as a set partition of the positions.
  • CycleTypePermutation → IntegerPartitionsurjectionSurjectionGraded mapMp00108The multiset of cycle lengths, as a partition.
  • CyclicShiftPermutation → PermutationinverseBijectionGraded mapMp00279Rotate the word one place to the left.
  • DescentBottomWordPermutation → BinaryWordsurjectionSurjectionGraded mapMp00131Letter v is 1 when value v is a descent bottom: some larger value immediately precedes it.
  • DescentCompositionPermutation → IntegerCompositionsurjectionSurjectionGraded mapMp00071The composition of n cut at the descent positions.
  • DescentSetPermutation → FinsetThe positions where the word falls.
  • DescentTopWordPermutation → BinaryWordsurjectionSurjectionGraded mapMp00130Letter v - 1 is 1 when value v is a descent top: some smaller value immediately follows it.
  • DescentWordPermutation → BinaryWordsurjectionSurjectionGraded mapMp00109Letter i is 1 when the word falls between positions i and i + 1: the descent set as a binary word.
  • FoataPermutation → PermutationbijectionBijectionGraded mapMp00087Foata's fundamental bijection: cycles rotated to their max, ordered by increasing max, parentheses erased.
  • FoataInversionsToMajorPermutation → PermutationbijectioninverseBijectionGraded mapMp00175The inverse of Foata's major-to-inversions bijection: peel off the last letter, rotate the blocks of the rest back.
  • FoataMajorToInversionsPermutation → PermutationbijectioninverseBijectionGraded mapMp00067Foata's bijection: each letter is put on the end of the image so far, which is cut into blocks, and every block is rotated one place right.
  • FromPermutationPermutation → IncreasingBinaryTreeThe increasing binary tree built by minimum-splitting recursion: the position of the smallest value roots the tree, everything before it recurses to the left, everything after it to the right.
  • InversePermutation → PermutationinvolutionBijectionGraded mapInvolutionMp00066The inverse permutation: position of each value.
  • InverseAfterComplementAfterReversePermutation → PermutationReverse, then complement, then invert.
  • InverseCyclicShiftPermutation → PermutationinverseRotate the word one place to the right.
  • InverseFoataPermutation → PermutationbijectioninverseBijectionGraded mapMp00086The permutation whose cycles are the stretches of the word between successive left-to-right maxima, each read as a cycle.
  • InverseKrewerasComplementPermutation → PermutationbijectioninverseBijectionGraded mapMp00089cπ⁻¹ with the long cycle c = (1 2 ... n), FindStat's order: position i holds π⁻¹(c(i)).
  • InverseToricPromotionPermutation → PermutationbijectioninverseBijectionGraded mapMp00309The same swaps as ToricPromotion in the opposite order: n and 1, then n - 1 and n, down to 1 and 2.
  • KnuthClassRepresentativePermutation → PermutationidempotentThe row reading word of σ's RSK insertion tableau — the canonical word of its Knuth (plactic) class.
  • KrewerasComplementPermutation → PermutationbijectionBijectionGraded mapMp00088π⁻¹c with the long cycle c = (1 2 ... n), FindStat's order: position i holds c(π⁻¹(i)).
  • LeftToRightMaximaDyckPathPermutation → DyckPathsurjectionSurjectionGraded mapMp00127The Dyck path whose rises climb to each left-to-right maximum and whose falls run to the next one.
  • LehmerCodeRotationPermutation → PermutationbijectionBijectionGraded mapMp00149The permutation whose Lehmer code is this one's with every entry one larger, cyclically.
  • LehmerCodeToMajorCodePermutation → PermutationbijectioninverseBijectionGraded mapMp00062The permutation whose major code is this permutation's Lehmer code.
  • LongCycleConjugationPermutation → PermutationbijectionBijectionGraded mapMp00265Conjugation by the long cycle (1 2 ... n): each cycle's entries shifted up by one, cyclically.
  • MajorCodeToLehmerCodePermutation → PermutationbijectioninverseBijectionGraded mapMp00073The permutation whose Lehmer code is this permutation's major code.
  • PeakSetPermutation → FinsetThe interior positions that rise then fall.
  • PermutahedronVertexPermutation → FinsetThe vertex (σ(1), …, σ(n)), or its Loday point, is an ordered tuple of coordinates, while finset is an unordered set of positions (the carrier DescentSet and PeakSet use). Reordering the coordinates gives a different vertex but the same finset, so the map would not be injective. A finset-valued PermutahedronVertex is a type mismatch, not a gap to close.
  • ReversePermutation → PermutationinvolutionBijectionGraded mapInvolutionMp00064The word read backwards.
  • ReverseComplementPermutation → PermutationinvolutionReverse, then complement.
  • RskPermutation → StandardTableauPairThe RSK correspondence: the insertion and recording tableaux, as a pair.
  • RskInsertionPermutation → StandardTableausurjectionSurjectionGraded mapMp00059The insertion tableau of the RSK correspondence.
  • RskRecordingPermutation → StandardTableausurjectionSurjectionGraded mapMp00070The recording tableau of the RSK correspondence, as its rows.
  • RskShapePermutation → IntegerPartitionsurjectionSurjectionGraded mapMp00060The common shape of the RSK tableaux: the row lengths, as a partition of n.
  • RunSortPermutation → PermutationidempotentIdempotentGraded mapMp00223The permutation with its increasing runs sorted lexicographically.
  • SignedPermutationPermutation → SignedPermutationInjectionGraded mapMp00170A permutation as the signed permutation with every sign positive.
  • SimionSchmidtPermutation → PermutationidempotentIdempotentGraded mapMp00068The left-to-right minima stay in place and the other positions take the remaining values, largest first: a 123-avoiding permutation.
  • SubexcedantSeqPermutation → SubexcedantSeqinverseEntry i counts the earlier entries larger than p(i): the permutation's inversion sequence.
  • ToLehmerCodePermutation → PermutationInversionEntry i counts the later entries smaller than p(i).
  • ToricPromotionPermutation → PermutationbijectioninverseBijectionGraded mapMp00310Toric promotion of the path graph: swap the values 1 and 2, then 2 and 3, and so on up to n and 1, each swap skipped when the two values sit next to each other.
  • WeakExceedancePartitionPermutation → SetPartitionSurjectionGraded mapMp00240The coarsest set partition containing every arc from i to π(i) with i ≤ π(i).

To Permutation

  • Avoiding132PermutationDyckPath → PermutationInjectionGraded mapMp00025The 132-avoiding permutation of Krattenthaler's bijection, built from the path's area sequence read from the end.
  • Avoiding312PermutationDyckPath → PermutationInjectionGraded mapMp00031The 312-avoiding permutation of Bandlow and Killpatrick: from the identity, each area-sequence entry swaps neighbouring positions that many times.
  • Avoiding321PermutationDyckPath → PermutationInjectionGraded mapMp00024The 321-avoiding permutation whose RSK pair is the pair of two-row tableaux read off the first and last halves of the path.
  • BilleyJockuschStanleyPermutationDyckPath → PermutationInjectionGraded mapMp00129The 321-avoiding permutation with entry (ups through a valley) + 1 at the position of its downs through that valley: the Billey-Jockusch-Stanley bijection.
  • BlockConcatenationSetComposition → PermutationsurjectionSurjectionGraded mapMp00286The permutation that lists the blocks in order, each sorted increasingly.
  • CarPermutationParkingFunction → PermutationSurjectionGraded mapMp00053Spot j holds the car that parks there, each car taking the first free spot at or after its preference.
  • IncreasingCyclePermutationSetPartition → PermutationInjectionGraded mapMp00080The permutation whose cycles are the blocks, each cycle increasing: every element goes to the next larger in its block, the largest to the least.
  • KrattenthalerPermutationDyckPath → PermutationInjectionGraded mapMp00119The 321-avoiding permutation whose left-to-right maxima are the path's peaks: Krattenthaler's bijection.
  • LabelingPermutationParkingFunction → PermutationSurjectionGraded mapMp00055The labeling of the parking function's support Dyck path: the positions of the entries, smallest entry first and equal entries left to right.
  • NoncrossingPermutationDyckPath → PermutationInjectionGraded mapMp00023The noncrossing permutation Stump's bijection gives the path: the cycles of its touch points, peeled off round by round.
  • PermutationCycleDecomposition → PermutationinverseThe permutation a cycle decomposition describes.
  • PermutationSubexcedantSeq → PermutationinverseThe permutation a subexcedant sequence is the inversion sequence of.
  • ReadingWordStandardTableau → PermutationInjectionGraded mapMp00081The rows read left to right, from the bottom row up, as a permutation.
  • RingelDyckPath → PermutationInjectionGraded mapMp00201The Ringel permutation of the Nakayama algebra whose Kupisch series the path gives, one size up.
  • StandardizationSignedPermutation → PermutationsurjectionSurjectionGraded mapMp00245The permutation of the same relative order, taking 1 < … < n < −n < … < −1.
  • StandardPermutationBinaryWord → PermutationGraded mapMp00336The permutation ranking the letters of the word, equal letters from left to right.
  • ToPermutationStandardTableauPair → PermutationinverseThe permutation an RSK pair comes from: inverse RSK.
  • UnderlyingPermutationSignedPermutation → PermutationsurjectionSurjectionGraded mapMp00163The permutation left when the signs are forgotten.
32 more in FindStat, not implemented here
  • Mp00002AlternatingSignMatrix → PermutationSurjectionGraded mapto left key permutation
  • Mp00014BinaryTree → PermutationInjectionGraded mapto 132-avoiding permutation
  • Mp00017BinaryTree → PermutationInjectionGraded mapto 312-avoiding permutation
  • Mp00058PerfectMatching → PermutationInjectionGraded mapto permutation
  • Mp00061Permutation → BinaryTreeSurjectionGraded mapto increasing tree
  • Mp00063Permutation → AlternatingSignMatrixInjectionGraded mapto alternating sign matrix
  • Mp00065Permutation → PosetsGraded mappermutation poset
  • Mp00075SemistandardTableau → PermutationGraded mapreading word permutation
  • Mp00159Permutation → PermutationGraded mapDemazure product with inverse
  • Mp00160Permutation → LabeledGraphGraded mapgraph of inversions
  • Mp00204Permutation → IntegerPartitionSurjectionGraded mapLLPS
  • Mp00208Permutation → Latticeslattice of intervals
  • Mp00209Permutation → Posetspattern poset
  • Mp00235Permutation → PermutationBijectionGraded mapdescent views to invisible inversion bottoms
  • Mp00236Permutation → PermutationBijectionGraded mapClarke-Steingrimsson-Zeng inverse
  • Mp00237Permutation → PermutationBijectionGraded mapdescent views to invisible inversion bottoms
  • Mp00238Permutation → PermutationBijectionGraded mapClarke-Steingrimsson-Zeng
  • Mp00239Permutation → PermutationBijectionGraded mapInvolutionCorteel
  • Mp00241Permutation → PermutationBijectionGraded mapInvolutioninvert Laguerre heap
  • Mp00248Permutation → IntegerCompositionGraded mapDEX composition
  • Mp00252Permutation → PermutationSurjectionrestriction
  • Mp00253DecoratedPermutation → PermutationSurjectionGraded mappermutation
  • Mp00254Permutation → PermutationIdempotentInverse fireworks map
  • Mp00255DecoratedPermutation → PermutationGraded maplower permutation
  • Mp00256DecoratedPermutation → PermutationGraded mapupper permutation
  • Mp00257Permutation → PermutationBijectionGraded mapInvolutionAlexandersson Kebede
  • Mp00277Permutation → PermutationGraded mapcatalanization
  • Mp00283PerfectMatching → PermutationInjectionGraded mapnon-nesting-exceedence permutation
  • Mp00305Permutation → ParkingFunctionInjectionGraded mapparking function
  • Mp00325Permutation → PermutationBijectionGraded mapones to leading
  • Mp00326Permutation → PermutationBijectionGraded mapweak order rowmotion
  • Mp00329Permutation → PermutationBijectionTanimoto

Enumeration

Examples

1 more kept as data, checked against the oracles
Basic #

Count(SeparablePermutations(5))=90Count(SeparablePermutations(5)) = 90, the large Schröder numbers A006318

live ↗
InCount(SeparablePermutations(5))\mathrm{Count}(\mathrm{SeparablePermutations}(5))Out9090
About
Examples2
CrosswalkOEIS

See also: SimplePermutations, Count, At