Skip to content

DistinctSubsequenceCount ​

The distinct subsequences, the empty one included.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000518via BinaryWord✓
DistinctSubsequenceCount(word)The distinct subsequences, the empty one included.
Typed signatures
TypePackageApplies
(binary_word) -> numbercombinatoricsalways

Domain: Binary word statistics

Details
  • Defined over BinaryWord as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a BinaryWord 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.
  • 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

Basic #

the word 110100111110100111

live ↗
InDistinctSubsequenceCount(BinaryWord⁡([1,1,0,1,0,0,1,1,1]))\mathrm{DistinctSubsequenceCount}({\operatorname{BinaryWord}}([1, 1, 0, 1, 0, 0, 1, 1, 1]))Out7878
Properties #

FindStat's value for 0

live ↗
InCombinatorialStat(BinaryWord⁡([0]),DistinctSubsequenceCount)\mathrm{CombinatorialStat}({\operatorname{BinaryWord}}([0]), \text{DistinctSubsequenceCount})Out22

Known value · FindStat St000518

FindStat's value for 1

live ↗
InCombinatorialStat(BinaryWord⁡([1]),DistinctSubsequenceCount)\mathrm{CombinatorialStat}({\operatorname{BinaryWord}}([1]), \text{DistinctSubsequenceCount})Out22

Known value · FindStat St000518

FindStat's value for 00

live ↗
InCombinatorialStat(BinaryWord⁡([0,0]),DistinctSubsequenceCount)\mathrm{CombinatorialStat}({\operatorname{BinaryWord}}([0, 0]), \text{DistinctSubsequenceCount})Out33

Known value · FindStat St000518

About
Examples4
CrosswalkFindStat