Skip to content

SchroederPaths ​

A name from the enumeratio catalogue with no kernel of its own yet; this page carries its crosswalk only.

Catalogued in the enumeratio database, with crosswalk rows in oeis; not yet written up here.

✓ checked against that system · ! checked, with disagreements (hover a chip)OEISA006318✓A155069✓
SchroederPaths(...)Catalogued in the enumeratio database, with crosswalk rows in oeis; not yet written up here.
Typed signatures
TypePackageApplies
(integer<0..>) -> indexed_collection<schroeder_path>combinatoricsalways

Domain: Combinatorics

Definition

Epsil, as the implementation runs it.

count(_n)

0 if 0 > _n else _tables[2 * _n * (_n + 1) + 0 + 1]

unrank(_n, _r)

Drop(Fold(Function(us if us[3] == 0 else Apply(
                                                (uc0: integer) => Join(
                                                                        [
                                                                          us[1] -
                                                                          0,
                                                                          us[2] +
                                                                          1,
                                                                          us[3] -
                                                                          1,
                                                                          1,
                                                                        ],
                                                                        Drop(us, 4),
                                                                        [1],
                                                                      ) if us[1] <
                                                                          uc0 else Apply(
                                                                                       (uc1: integer) => Join([
                                                                                                                us[1] - uc0,
                                                                                                                us[2] + 0,
                                                                                                                us[3] - 2,
                                                                                                                1,
                                                                                                              ], Drop(us, 4), [2]) if us[1] <
                                                                                                                                     uc0 + uc1 else Join([us[1] -
                                                                                                                                                 (uc0 + uc1), us[2] - 1, us[3] - 1, 1], Drop(us, 4), [-1]),
                                                                                       (0 if us[2] + 0 >
                                                                                             _n else _tables[(us[3] - 2) *
                                                                                                           (_n + 1) +
                                                                                                           us[2] + 0 +
                                                                                                           1]) if 2 <= us[3] &&
                                                                                                                 us[2] + 0 >=
                                                                                                                 0 else 0,
                                                                                     ),
                                                (0 if us[2] + 1 > _n else _tables[(us[3] - 1) *
                                                                                  (_n + 1) +
                                                                                  us[2] + 1 +
                                                                                  1]) if 1 <= us[3] &&
                                                                                        us[2] + 1 >=
                                                                                        0 else 0,
                                              ), us, ui), [_r, 0, 2 * _n, 1], Range(
                                                                                    1,
                                                                                    2 * _n,
                                                                                    1,
                                                                                  )), 4)

rank(_n, _x)

Fold(Function(Apply(
                     (rc0: integer) => [rs[1] + 0, rs[2] + 1, rs[3] - 1, 1] if rx ==
                                                                               1 else Apply(
                                                                                            (rc1: integer) => [
                                                                                                                rs[1] + rc0,
                                                                                                                rs[2] + 0,
                                                                                                                rs[3] - 2,
                                                                                                                1,
                                                                                                              ] if rx == 2 else [rs[1] +
                                                                                                                                rc0 + rc1, rs[2] - 1, rs[3] - 1, 1],
                                                                                            (0 if rs[2] + 0 >
                                                                                                  _n else _tables[(rs[3] - 2) *
                                                                                                                (_n + 1) +
                                                                                                                rs[2] + 0 +
                                                                                                                1]) if 2 <= rs[3] &&
                                                                                                                      rs[2] + 0 >=
                                                                                                                      0 else 0,
                                                                                          ),
                     (0 if rs[2] + 1 > _n else _tables[(rs[3] - 1) * (_n + 1) +
                                                       rs[2] + 1 + 1]) if 1 <= rs[3] && rs[2] +
                                                                           1 >= 0 else 0,
                   ), rs, rx), [0, 0, 2 * _n, 1], _x)[1]

valid(_n, _x)

Apply(
       (ve: list<integer>) => ve[1] == 0 && ve[2] == 2 * _n,
       Fold(
             Function(vs if vs[1] < 0 else [
                                             vs[1] + 1,
                                             vs[2] + 1,
                                             Max(vs[3], vs[1] + 1),
                                           ] if vx == 1 else [
                                                              vs[1] + 0,
                                                              vs[2] + 2,
                                                              Max(
                                                                   vs[3],
                                                                   vs[1] + 0,
                                                                 ),
                                                            ] if vx == 2 else [
                                                                               vs[1] -
                                                                               1,
                                                                               vs[2] +
                                                                               1,
                                                                               Max(vs[3], vs[1] - 1),
                                                                             ] if vx == -1 else [-1, 0, 0], vs, vx),
             [0, 0, 0],
             _x,
           ),
     )

tables(_n)

Fold(
      Function(
                Join(
                      t_t,
                      Fold(
                            Function(
                                      ReplaceAt(
                                                 t_row,
                                                 t_c + 1,
                                                 0 if t_s < t_c else (t_t[(t_s -
                                                                           1) *
                                                                          (_n +
                                                                           1) + t_c +
                                                                             1 +
                                                                          1] if t_c +
                                                                               1 <=
                                                                               _n else 0) +
                                                                     (t_t[(t_s -
                                                                           2) *
                                                                          (_n +
                                                                           1) + t_c +
                                                                             0 +
                                                                          1] if t_s >=
                                                                               2 else 0) +
                                                                     (t_t[(t_s -
                                                                           1) *
                                                                          (_n +
                                                                           1) +
                                                                          (t_c -
                                                                           1) + 1] if t_c -
                                                                               1 >=
                                                                               0 else 0),
                                               ),
                                      t_row,
                                      t_c,
                                    ),
                            Map(Function(0, t_z), Range(0, _n + 1 - 1, 1)),
                            Range(0, _n + 1 - 1, 1),
                          ),
                    ),
                t_t,
                t_s,
              ),
      Fold(
            Function(
                      ReplaceAt(t_row, t_c + 1, 1 if t_c == 0 else 0),
                      t_row,
                      t_c,
                    ),
            Map(Function(0, t_z), Range(0, _n + 1 - 1, 1)),
            Range(0, _n + 1 - 1, 1),
          ),
      Range(1, 2 * _n + 1 - 1, 1),
    )

Enumeration

Examples

Basic #

The large Schröder numbers: 1,2,6,22,90,…1, 2, 6, 22, 90, \ldots

live ↗
InCount(SchroederPaths(4))\mathrm{Count}(\mathrm{SchroederPaths}(4))Out9090

All Schröder paths of semilength 22

live ↗
InTake(SchroederPaths(2),6)\mathrm{Take}(\mathrm{SchroederPaths}(2), 6)Out[SchroederPath⁡([1,1,−1,−1]),SchroederPath⁡([1,2,−1]),SchroederPath⁡([1,−1,1,−1]),SchroederPath⁡([1,−1,2]),SchroederPath⁡([2,1,−1]),SchroederPath⁡([2,2])]\bigl\lbrack{\operatorname{SchroederPath}}([1, 1, -1, -1]), {\operatorname{SchroederPath}}([1, 2, -1]), {\operatorname{SchroederPath}}([1, -1, 1, -1]), {\operatorname{SchroederPath}}([1, -1, 2]), {\operatorname{SchroederPath}}([2, 1, -1]), {\operatorname{SchroederPath}}([2, 2])\bigr\rbrack
About
Examples2
CrosswalkOEIS ×2