Skip to content

LongestPalindromicSubsequence ​

The length of the longest subsequence that reads the same backwards.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt001417via BinaryWord✓
LongestPalindromicSubsequence(word)The length of the longest subsequence that reads the same backwards.
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 St001417: the longest common subsequence of the word and its reverse. After the first i letters, entry j + 1 holds that for the first j letters of the reverse.

Definition

Epsil, as the implementation runs it.

on BinaryWord, over _x

0 if Length(_x) < 1 else Apply(
                                (a_init: list<integer>) => Fold((
                                                                  a: list<integer>,
                                                                  b,
                                                                ) => Apply(
                                                                           (a_next: list<integer>) => a_next,
                                                                           Join(
                                                                                 [0],
                                                                                 Map(Function(Max(
                                                                                                   a[j + 1],
                                                                                                   Max(Join(
                                                                                                             [0],
                                                                                                             Map(
                                                                                                                  Function(a[jp] + 1 if _x[b] ==
                                                                                                                                        _x[Length(_x) + 1 -
                                                                                                                                           jp] else 0, jp),
                                                                                                                  Range(1, j, 1),
                                                                                                                ),
                                                                                                           )),
                                                                                                 ), j), Range(1, Length(_x))),
                                                                               ),
                                                                         ), a_init, Range(1, Length(_x))),
                                Map(Function(0, z), Range(0, Length(_x), 1)),
                              )[Length(_x) + 1]

Examples

Basic #

the word 110100111110100111

live ↗
InLongestPalindromicSubsequence(BinaryWord⁡([1,1,0,1,0,0,1,1,1]))\mathrm{LongestPalindromicSubsequence}({\operatorname{BinaryWord}}([1, 1, 0, 1, 0, 0, 1, 1, 1]))Out88
Properties #

FindStat's value for 0

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

Known value · FindStat St001417

FindStat's value for 1

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

Known value · FindStat St001417

FindStat's value for 00

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

Known value · FindStat St001417

About
Examples4
CrosswalkFindStat