DistinctSubsequenceCount
The distinct subsequences, the empty one included.
✓ checked against that system · ! checked, with disagreements (hover a chip)FindStat
St000518via BinaryWord✓DistinctSubsequenceCount(word)The distinct subsequences, the empty one included.Typed signatures
| Type | Package | Applies |
|---|---|---|
(binary_word) -> number | combinatorics | always |
Details
- Defined over
BinaryWordas an expression in_x, evaluated by compute-engine — the definition IS the implementation. - Takes a
BinaryWordand 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. - FindStat's St000518. With d(j) the count for the first j letters, d(j) = 2 d(j - 1) less d(p - 1), where p is the latest earlier position holding the same letter, if any.
Definition
Epsil, as the implementation runs it.
on BinaryWord, over _x
1 if Length(_x) < 1 else Apply((a_init: list<integer>) => Fold(
(
a: list<integer>,
b,
) => Apply(
(a_next: list<integer>) => a_next,
Join(
a,
[2 * a[Length(a)] -
a[Max(Join(
[0],
Map(
Function(p if _x[p] == _x[b] else 0, p),
Range(1, b - 1, 1),
),
)) +
1]],
),
),
a_init,
Range(
1,
Length(_x),
),
), [0, 1])[Length(_x) +
2]Examples
Properties #
About
| Examples | 4 |
|---|---|
| Crosswalk | FindStat |