Skip to content

LongestZigzag ​

The length of the longest stretch of steps that alternate between up and down.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000981via DyckPath✓
LongestZigzag(path)The length of the longest stretch of steps that alternate between up and down.
Typed signatures
TypePackageApplies
(dyck_path) -> numbercombinatoricsalways

Domain: Dyck path statistics

Details
  • Defined over DyckPath as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a DyckPath and nothing else — it reads values against their positions, or walks the orbits, so it needs the bijection. Applying it to a bare list is a type error, not a wrong answer.
  • Starts the count again at 1 on a repeated step; the accumulator is (best, current, previous step), with 2 for no previous step.

Definition

Epsil, as the implementation runs it.

on DyckPath, over _x

Fold(Function([a[1], 1, b] if a[3] == b else [
                                               Max([a[1], a[2] + 1]),
                                               a[2] + 1,
                                               b,
                                             ], a, b), [0, 0, 2], _x)[1]

Examples

Basic #

the step word UUDDUDUUDDUD

live ↗
InLongestZigzag(DyckPath⁡([1,1,0,0,1,0]))\mathrm{LongestZigzag}({\operatorname{DyckPath}}([1, 1, 0, 0, 1, 0]))Out33

the step word UDUUDDUDUUDD

live ↗
InLongestZigzag(DyckPath⁡([1,0,1,1,0,0]))\mathrm{LongestZigzag}({\operatorname{DyckPath}}([1, 0, 1, 1, 0, 0]))Out33
Properties #

FindStat's value for [1,0,1,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,0,1,0]),LongestZigzag)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 0, 1, 0]), \text{LongestZigzag})Out44

Known value · FindStat St000981

FindStat's value for [1,1,0,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,1,0,0]),LongestZigzag)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 1, 0, 0]), \text{LongestZigzag})Out22

Known value · FindStat St000981

FindStat's value for [1,0,1,0,1,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,0,1,0,1,0]),LongestZigzag)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 0, 1, 0, 1, 0]), \text{LongestZigzag})Out66

Known value · FindStat St000981

About
Examples5
CrosswalkFindStat