Palindromes and repeats
On 24 out, 20:39, Luciano Paulino da Silva
wrote:
On 24 out, 20:10, John Coleman wrote:
[snip]
DearLuciano,
I noticed a potential problem with the code that I've written for you.
The problem is it handles overlapping palindromes. For example, if you
input ABBACCABCC, my code first detects the ABBA then starts looking
for palindromes in the remaining string (CCABCC). That is how I
interpreted you in your second post when you said "I forgot to say
that it would be selected the palindromes as big as detected from the
order they appear in the text. So, if a big palindrome is detected the
next one will be the following after it in the string even when there
are a palindrome inside it. " But notice that this way of handling
things misses BACCAB which begins in the third position since it
overlaps with ABBA. Similar questions will arise in repeat detection -
so I want to clarify things before proceeding further. What would you
like the palindrome output to be in the case of ABBACCABCC?
-John
Dear John,
Thank you for your attention. You are correct and I have realized it
some hours ago. We must always detect the biggest palindrome linearly
according to their occurrence on the string following by smallest
palindromes excluding that palindromes that were inside the initially
detected palindrome. In this way, the output for your example it would
be:
Input: ABBACCABCC
Output:
BACCAB
CC
But anycase it is possible in the future that we require test other
situations. Thanks in advance!
Luciano
So you *don't* want ABBA as part of the output?
What would the output be for BAABABBACCABCC?
-John
Dear John,
Since ABBA woukd be smaller than BACCAB, at present it would not be
detected.
In your example:
Input: BAABABBACCABCC
Output:
BAAB
BACCAB
CC
Dear John,
I was thinking about the possibility that we could perform the choice
of a rule before perform palindromes or repeats detection. Since
detection of all palindromes including that inside other palindromes,
and maximal palindromes, and all other rules we could think about. Do
you think that it would be possible?
Thanks in advance,
Luciano
|