View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default Palindromes and repeats

On Oct 29, 2:08*pm, Luciano Paulino da Silva
wrote:
Dear John,
I performed the folloing input string:
GQGAGQGAGAAAAAAGGAGQGGYGGLGNQGAGRGGQGAAAAAAGGAGQGG YGGLGSQGAGRGGLGGQGAGAAAAA*AGGAGQGGYGGLGGQGAGQGAGQG GYGGLGIQGSGRGGLGGQGAGAAAAAAGGAGQGGLGGQGAGQGAGAAAAA A*GGVRQGGYGGLGSQGAGRGGQGAGAAAAAAGGAGQGGYGGLGGQGVGR GGLGGQGAGAAAAGGAGQGGYGGVGSG*ASAASAAASRLSSPQASSRVSS AVSNLVASGPTNSAALSSTISNVVSQIGASNPGLSGCDVLIQALLEVVSA LIQ*ILGSSSIGQVNYGSAGQATQIVGQSVYQALG


[snip]

Dear Luciano,

The purpose of sub Display() was not to replace Main() - it was simply
to show what sort of data Initialize() was collecting since you
indicated that you couldn't figure out what that subroutine was doing
(which isn't surprising since I made little effort to comment the code
and the algorithm is somewhat invovled). If you find the output of
Display() confusing then it is maybe more trouble than it is worth. I
wrote it mostly for myself for debugging purposes anyway. You can
delete it from the project with no ill-effect.

If you want to understand the output a bit more, consider the
following bit:

[snip]

18 * * *9 * * * AGA * * 3 * * * 8 * * * 10
19 * * *9.5 * * 2 * * * 0 * * * 10 * * *9
20 * * *10 * * *A * * * 1 * * * 10 * * *10
21 * * *10.5 * *AA * * *2 * * * 10 * * *11
22 * * *11 * * *AAA * * 3 * * * 10 * * *12
23 * * *11.5 * *AAAA * *4 * * * 10 * * *13
24 * * *12 * * *AAAAA * 5 * * * 10 * * *14
25 * * *12.5 * *GAAAAAAG * * * *8 * * * 9 * * * 16
26 * * *13 * * *AAAAA * 5 * * * 11 * * *15
27 * * *13.5 * *AAAA * *4 * * * 12 * * *15
28 * * *14 * * *AAA * * 3 * * * 13 * * *15
29 * * *14.5 * *AA * * *2 * * * 14 * * *15
30 * * *15 * * *A * * * 1 * * * 15 * * *15
31 * * *15.5 * * * * * *0 * * * 16 * * *15


[snip]

AGA is a plaindrome of length 3 which runs from string position 8 to
10. It is thus centered at 9 = 18/2

GAAAAAAG is a palindrome of length 8 which extends from 9 to 16.
Unlike AGA, it has no middle character. Instead, the "center" of the
palindrome falls between GAAA and AAAG, which I refer to as position.

Don't worry about this output too much. It is probably a better use of
time to give Main() a battery of tests. On the other hand, if either
you or someone on your team is going to maintain or modify the code,
then I could try to write up a brief description of the algorithm and
comment the code more.

Sorry for any confusion.

-John