I need algorithm for my task
denismfmcmahon at gmail.com
Thu Nov 6 04:14:16 CET 2014
On Wed, 05 Nov 2014 18:49:01 +0000, MRAB wrote:
> On 2014-11-05 18:05, C at rlos wrote:
>> I thing this work:
>> foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ]
> It doesn't work for the final example or "barbaz".
I have two algorithms I've implemented.
Still not sure exactly which algorithm he wants though. The first one is
as he describes, in that the word is only reported if it's repeated, else
report the whole string.
The second algorithm reads up until the first letter is repeated, or
reports the whole string if no repeat found.
I did see a third algorithm suggested, I should add that and see what
OK, implemented the third algorithm (repeat first n chars of s int(n/len
(s))+1 times, truncate to len(s) and compare with s), I also added
another test case, now my test cases are:
t = ["pythonpythonpyth", "DOLORIUMD", "HELLOLHELLO", "thewordword",
and my output is:
python DOLORIUMD HELLOLHELLO thewordword barbaz dib
python DOLORIUM HELLOL thewordword bar dib
python DOLORIUM HELLOL thewordword barbaz dibdibdob
I wonder which of these three is actually the algorithm the OP wants.
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list