Maximum Presufix¶
We define presufix of s as a string such that is both prefix and sufix of s.
Any s might have several presufix and we are interested in the one with maximum length that is not equal to s: the maxpresufix.
For instance, 'a' and 'abba' are both presufix of 'abbabba', being the later the longest one.
You are required to deliver the following function in the module maxpresufix (file maxpresufix.py):
- maxpresufix(n)¶
such that
For example:
>>> maxpresufix('abbabba') 'abba' >>> maxpresufix('abcdef') ''
Doctests are available in the maxpresufix.test file.