Mar-20-2022, 04:58 AM
(This post was last modified: Mar-20-2022, 04:58 AM by deanhystad.)
Ask specific questions. You must understand some of it. If not, trying to explain it to you is a waste of everybody's time. You wont understand the explanations.
I appears to be a palindrome generator.
i is start of the palindrome (alpha[i]).
Two sequences are calculated. One counts down from i to zero and then back up, the other counts down from (n-j-1) to zero and back up.
The two sequences cross at the center.
The lesser value from the two sequences is used for the palindrome.
Each sequence is responsible for producing half of the palindrome.
Assume n == 5
Look at what abs(i-j) produces: (0, 1, 2, 3, 4), (1, 0, 1, 2, 3), (2, 1, 0, 1, 2), (3, 2, 1, 0, 1), (4, 3, 2, 1, 0).
Look at what abs(n - i - j - 1) % len(alpha)) produces: (4, 3, 2, 1, 0), (3, 2, 1, 0, 1), (2, 1, 0, 1, 2), (1, 0, 1, 2, 3), (0, 1, 2, 3, 4)
I appears to be a palindrome generator.
i is start of the palindrome (alpha[i]).
Two sequences are calculated. One counts down from i to zero and then back up, the other counts down from (n-j-1) to zero and back up.
The two sequences cross at the center.
The lesser value from the two sequences is used for the palindrome.
Each sequence is responsible for producing half of the palindrome.
Assume n == 5
Look at what abs(i-j) produces: (0, 1, 2, 3, 4), (1, 0, 1, 2, 3), (2, 1, 0, 1, 2), (3, 2, 1, 0, 1), (4, 3, 2, 1, 0).
Look at what abs(n - i - j - 1) % len(alpha)) produces: (4, 3, 2, 1, 0), (3, 2, 1, 0, 1), (2, 1, 0, 1, 2), (1, 0, 1, 2, 3), (0, 1, 2, 3, 4)