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)FindStat
St000981via DyckPath✓LongestZigzag(path)The length of the longest stretch of steps that alternate between up and down.Typed signatures
| Type | Package | Applies |
|---|---|---|
(dyck_path) -> number | combinatorics | always |
Details
- Defined over
DyckPathas an expression in_x, evaluated by compute-engine — the definition IS the implementation. - Takes a
DyckPathand 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
Properties #
About
| Examples | 5 |
|---|---|
| Crosswalk | FindStat |