Detecting repeated subsequences of identical items

Ethan Furman ethan at stoneleaf.us
Wed Apr 20 23:57:13 EDT 2016


On 04/20/2016 08:07 PM, Steven D'Aprano wrote:

> Now I want to group subsequences. For example, I have:
>
> "ABCABCABCDEABCDEFABCABCABCB"
>
> and I want to group it into repeating subsequences. I can see two ways to
> group it:
>
> ABC ABC ABCDE ABCDE F ABC ABC ABC B
>
> giving counts:
>
> (ABC) count = 2
> (ABCDE) count = 2
> F count = 1
> (ABC) count = 3
> B repeats 1 time

or

ABC ABC ABC D E A B C D E F ABC ABC B

--
~Ethan~



More information about the Python-list mailing list