Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80288

Re: I need algorithm for my task

Date 2014-11-05 13:05 -0500
From "C@rlos" <cmferras@estudiantes.uci.cu>
Subject Re: I need algorithm for my task
Newsgroups comp.lang.python
Message-ID <mailman.15513.1415210732.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I thing this work: 

stg='pythonpython' 
foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ] 

On 2014-11-05 11:58, lordvital21@gmail.com wrote: 
> I have line 'pythonpythonpyth'. How do I know which word is the foundation line?. 
> Other examples: 
> "pythonpythonpyth" is python 
> "DOLORIUMD" is DOLORIUM 
> "HELLOLHELLO" is HELLOL 
> "thewordword" is thewordword 
> 
> I need to know whether the word in the text is repeated and get it. This will be the key. 
> 
Consider the first example. 

If the foundation is the first 1 character 'p' and you repeat it enough 
times you'll get 'pppppppppppppppp'. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 2 characters 'py' and you repeat it 
enough times you'll get 'pypypypypypypypy'. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 3 characters 'py' and you repeat it 
enough times you'll get 'pytpytpytpytpytpyt'. 

This is longer than as the line, so truncate it to 'pytpytpytpytpytpy'. 

Does it match the line? No. 

OK. 

Continue in this vein until you'll get a match. (The foundation might 
in fact be the entire line.) 

-- 
https://mail.python.org/mailman/listinfo/python-list 

III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero del 2014. Ver www.uci.cu

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: I need algorithm for my task "C@rlos" <cmferras@estudiantes.uci.cu> - 2014-11-05 13:05 -0500

csiph-web