LongestPalindromicSubsequence
The length of the longest subsequence that reads the same backwards.
✓ checked against that system · ! checked, with disagreements (hover a chip)FindStat
St001417via BinaryWord✓LongestPalindromicSubsequence(word)The length of the longest subsequence that reads the same backwards.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 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
Properties #
About
| Examples | 4 |
|---|---|
| Crosswalk | FindStat |