Function Repository Resource:

PalindromicSubsequences

Source Notebook

Find palindromic subsequences in lists

Contributed by: Sander Huisman

ResourceFunction["PalindromicSubsequences"][list]

finds all palindromic subsequences in list.

ResourceFunction["PalindromicSubsequences"][list,min]

finds all palindromic subsequences in list with at least a length of min.

Details

For ResourceFunction["PalindromicSubsequences"][list], the minimum length is 2.
Single elements can be considered palindromes and can be included by ResourceFunction["PalindromicSubsequences"][list,1].

Examples

Basic Examples (1) 

Find palindromic subsequences:

In[1]:=
ResourceFunction[
 "PalindromicSubsequences"][{12, 13, 11, 13, 10, 8, 3, 9, 3, 8, 12, 11, 10, 7, 7, 10, 5, 5, 1, 27}]
Out[1]=

Scope (3) 

Include single-element palindromes:

In[2]:=
ResourceFunction[
 "PalindromicSubsequences"][{12, 11, 13, 10, 8, 3, 9, 3, 8, 13}, 1]
Out[2]=

The elements can be anything:

In[3]:=
ResourceFunction[
 "PalindromicSubsequences"][{RGBColor[1, 0, 0], "a", 3, x, 3, "a", 13,
   2}]
Out[3]=

Find palindromic subsequences in the largest 2-digit 19-smooth number:

In[4]:=
ResourceFunction["PalindromicSubsequences"][IntegerDigits[17 19^6]]
Out[4]=

Publisher

SHuisman

Version History

  • 1.0.0 – 08 August 2022

License Information