Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80288 > unrolled thread
| Started by | "C@rlos" <cmferras@estudiantes.uci.cu> |
|---|---|
| First post | 2014-11-05 13:05 -0500 |
| Last post | 2014-11-05 13:05 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Re: I need algorithm for my task "C@rlos" <cmferras@estudiantes.uci.cu> - 2014-11-05 13:05 -0500
| From | "C@rlos" <cmferras@estudiantes.uci.cu> |
|---|---|
| Date | 2014-11-05 13:05 -0500 |
| Subject | Re: I need algorithm for my task |
| Message-ID | <mailman.15513.1415210732.18130.python-list@python.org> |
[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 top | Article view | comp.lang.python
csiph-web