Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: Detecting repeated subsequences of identical items Date: Wed, 20 Apr 2016 20:57:13 -0700 Lines: 25 Message-ID: References: <571843f9$0$1585$c3e8da3$5496439d@news.astraweb.com> <57184F99.4090808@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de Q8b4QzHLse3uaZNr6r8NAg28mUSfAkqrH+G/XAKVLceQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Detecting': 0.16; 'wrote:': 0.16; 'have:': 0.18; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'skip:" 20': 0.26; '~ethan~': 0.29; "d'aprano": 0.33; 'steven': 0.33; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'abc': 0.91 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <571843f9$0$1585$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <57184F99.4090808@stoneleaf.us> X-Mailman-Original-References: <571843f9$0$1585$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:107434 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~