Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80284
| Date | 2014-11-05 17:53 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: I need algorithm for my task |
| References | <50a7df31-ee6c-45f5-9dd8-6ac895ec46cf@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15509.1415210010.18130.python-list@python.org> (permalink) |
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.)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I need algorithm for my task lordvital21@gmail.com - 2014-11-05 03:58 -0800
Re: I need algorithm for my task Chris Angelico <rosuav@gmail.com> - 2014-11-05 23:29 +1100
Re: I need algorithm for my task Darren Chen <ccylily1314@gmail.com> - 2014-11-06 17:42 -0800
Re: I need algorithm for my task Peter Otten <__peter__@web.de> - 2014-11-05 13:36 +0100
Re: I need algorithm for my task Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-05 15:19 +0000
Re: I need algorithm for my task MRAB <python@mrabarnett.plus.com> - 2014-11-05 17:53 +0000
Re: I need algorithm for my task wxjmfauth@gmail.com - 2014-11-05 11:07 -0800
Re: I need algorithm for my task wxjmfauth@gmail.com - 2014-11-05 11:29 -0800
Re: I need algorithm for my task wxjmfauth@gmail.com - 2014-11-05 22:31 -0800
csiph-web