I need algorithm for my task
rosuav at gmail.com
Wed Nov 5 13:29:31 CET 2014
On Wed, Nov 5, 2014 at 10:58 PM, <lordvital21 at 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.
This sounds like it's probably homework, so I won't actually give you
the code, just a starting hint.
Python lets you slice a string to get back a substring. Start with a
really simple algorithm like "see if the first N letters are also the
next N letters and so on until you pass the end of the string", then
word that up into Python code. Later on, you can look into making it
less naive, but start simple and work up from there.
More information about the Python-list