The algorithm might make more sense with a sample implementation to look at (here, in Python):
S = raw_input()
L = len(S)
T = 0
for i in range(L/2):
A = ord(S[i])
B = ord(S[L-1-i])
T += abs(A-B)
print T
Let's review the problem description. Each character decrement (e.g. --'b' == 'a'
) counts as a single operation. The problem is to determine the number of operations required to transform the input string into a palindrome.
The algorithm iterates over half the string, and compares the ordinal value of the character at the current index with that of the character across from it (in its mirrored position). If they are not the same, the one that is larger needs to be decremented, but it doesn't actually need to be checked which is which. Taking the absolute value of the difference will produce the correct number of operations needed regardless.
I think a source of confusion might be the wording, "Let's assume that one such set of indices can be denoted by A' and B'." I believe that the author intended A' and B' to refer to the characters at each of these indices, and not the indices themselves. If they had actually meant to refer to the indices, the algorithm would return the same value for any given string length, which is obviously incorrect.
A golfed version might look like this:
s=map(ord,raw_input())
print sum(abs(s[i]-s[~i])for i in range(len(s)/2))
I suspect Ruby might be a bit shorter, because indexing a string returns the ordinal value, rather than the individual character.