palindromic-revenge
Source: hackerearth
Difficulty: EASY

Mike lost in a coding contest just because he was not aware with the concept of palindrome properly.
So finally he learnt about it and decided to mess up with the Winners name of the contest as he will now meddle with letters of their names.
He will change all the names into palindrome and will follow these rules:

-We can only lower the values of alphabets e.g,. we can replace the letter c from b, q from p but cannot replace b from c or p from q.

-We can repeatedly lower any alphabet until it becomes ‘a’, after letter becomes ‘a’ we cannot lower it anymore.

Suppose each change i.e,. reduction costs 1 unit so how many minimum units would be required to convert whole name into palindrome.

Input Format:

The first line contains an integer T, i.e., the number of test cases. 
The next T lines will contain a string without spaces in lower case.

Output Format:

A single line containing the number of minimum units corresponding to each test case.

Constraints:

1 \; ≤ \; T\; ≤\; 15 

1 ≤ length of string ≤ 10 ^ 5 

SAMPLE INPUT
3
ada
acda
dceb

SAMPLE OUTPUT
0
1
4

Explanation

For test case 1,result would be 0 because string is already a palindrome.

For test case 2, acda->acca as we lowered d to c only,so result would be 1.

For test case 3, dceb->cceb->bceb->bcdb->bccb so result would be 4.


n = eval(input())
for _ in range(n):
	string = input()
	revstring = string[::-1]
	count = 0
	done = False
	if(revstring!=string):
		for i in range(len(string)):
			if(ord(string[i])>ord(revstring[i]) and not done):
				count+= (ord(string[i])-ord(revstring[i]))
				str1 = list(string)
				str1[i] = revstring[i]
				string = ''.join(str1)
				if(revstring==string):
					done = True
					break

	print(count)


t = int(input())
f ={}
for x in range(0,t):
	a = str(input())
	i = 0
	j = len(a)-1
	count = 0
	while(i <=j):
		if a[i] != a[j]:
			if((ord(a[j])>ord(a[i]))):
				tem = chr((ord(a[j])-1))
				a = a[:j]+tem+a[j+1:]
				count = count+1
			else:
				tem = chr((ord(a[i])-1))
				a = a[:i]+tem+a[i+1:]
				count = count+1
		else:
			i = i+1
			j = j-1
	f[x] = count
for i in range(0,t):
	print((f[i]))


t = eval(input())
o=[]
for i in range(0,t):
	l = input()
	l = list(l)
	bp = len(l)-1
	c=0
	for fp in range(0,len(l)/2):
		if l[fp]==l[bp]:
			bp-=1
			continue
		elif l[fp]>l[bp]:
			while l[fp]>l[bp]:
				l[fp] = chr(ord(l[fp])-1)
				c+=1
		else:
			while l[fp]<l[bp]:
				l[bp] = chr(ord(l[bp])-1)
				c+=1
		bp-=1	
	o.append(c)

for e in o:
	print(e)



t=int(input())
i=0
while i<t:
	s=input()
	q=len(s)-1
	j=0
	c=0
	while j<(q/2)+1:
		c+=abs(ord(s[j])-ord(s[q-j]))
		j=j+1
	i=i+1
	print(c)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
n = int(input())
i = 0
while i < n:
	tc = input()
	j = 0
	ans = 0
	while j < len(tc)/2:
		ans += abs(ord(tc[j]) - ord(tc[len(tc)-j-1]))	
		j += 1
	print(ans)
	
	i += 1


t=int(input())
while t>0:
	st1=input()
	st2=st1[::-1]
	if st1==st2:
		print('0')
	else:
		l=len(st1)
		st3=st1[:l/2]
		st4=st1[l/2:][::-1]
		c=0
		for i in range(l/2):
			c=c+abs(int(ord(st4[i]))-int(ord(st3[i])))
		print(c)	
	t=t-1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t="abcdefghijklmnopqrstuvwxyz"
for i in range(eval(input())):
	a=input()
	c=0
	if(a==a[::-1]):
		print("0")
	else:
		q=a[:len(a)/2]
		p=a[len(a)/2:]
		p=p[::-1]
		
		for i in range(len(q)):
			m=abs(int(ord(q[i]))-int(ord(p[i])))
			c=c+m
		print(c)


for i in range(eval(input())):
	ans=0
	data=input().strip()
	for x in range(len(data)/2):
		ans+=abs(ord(data[x])-ord(data[len(data)-x-1]))
	print(ans)


n=int(input())
for j in range(n):
	s=input()
	count=0
	if s=="".join(reversed(s)):
		print(count)
	else:
		l=len(s)/2
		if len(s)%2==0:
			a=s[:l]
		else:
			a=s[:l+1]
		b=list(reversed(s[l:]))
		d=list(zip(a,b))
		for k in range(len(d)):
			z=max(d[k][0],d[k][1])
			while z!=min(d[k][0],d[k][1]):
				z=ord(z)-1
				count+=1
				z=chr(z)
		print(count)
				
				
		


t=int(eval(input()))
c=[]
for i in range(t):
	c.append(input())
for i in range(t):
	count=0
	st=c[i]
	rev=st[::-1]
	for j in range((len(st)//2)):
		while ord(st[j])!=ord(rev[j]):
			if st[j]>rev[j]:
				n=ord(st[j])-1
				st=st[:j]+chr(n)+st[j+1:]
			else:
				n=ord(rev[j])-1
				rev=rev[:j]+chr(n)+rev[j+1:]
			count+=1
	print(count)



t=int(eval(input()))
c=[]
for i in range(t):
	c.append(input())
for i in range(t):
	count=0
	st=c[i]
	rev=st[::-1]
	for j in range((len(st)//2)):
		while ord(st[j])!=ord(rev[j]):
			if st[j]>rev[j]:
				n=ord(st[j])-1
				st=st[:j]+chr(n)+st[j+1:]
			else:
				n=ord(rev[j])-1
				rev=rev[:j]+chr(n)+rev[j+1:]
			count+=1
	print(count)



def palindrome(a):
	length=len(a)
	iterator=0
	#original_length=length-1
	while iterator<length:
		if a[iterator]==a[length-iterator-1]:
			pass
		else:
			return False
		iterator=iterator+1
		if iterator==length:
			return True
			
	
for _ in range(eval(input())):
	a=input()
	if palindrome(a):
		print("0")
		continue
	#print"after palin test"
	
	i=0
	strlen=len(a)-1
	number_of_changes=0
	
	while i<=strlen/2:
		temp=0
		if a[i]==a[strlen-i]:
			pass
		
		else:
			temp=abs(ord(a[i])-ord(a[strlen-i]))
			
			number_of_changes=number_of_changes + temp
		i=i+1
	print(number_of_changes)
		


for _ in range(int(input())):
	ct=0;	q=input();	i,j=0,len(q)-1;
	while i<j:		ct+=abs(ord(q[i])-ord(q[j]));	i+=1;	j-=1;
	print(ct);


t = int(input())
for cases in range(t):
	s = list(input())
	units = 0
	l = len(s)
	for i in range(int(l - l/2)):
		units += abs(ord(s[i]) - ord(s[l- i - 1]))
	print(units)


mod = 10**9 + 7
test = int(input())
for i in range(test):
	s = input()
	if s == s[::-1]:
		print(0)
	else:
		i , j = 0 , len(s)-1
		count = 0
		while i < j:
			count += abs( ord(s[i]) - ord(s[j]))
			i += 1
			j -= 1
		print(count)


t=int(input())
for i in range(t):
	a=input()
	c=0
	if(a==a[::-1]):
		print("0")
	else:
		m=a[:len(a)/2]
		n=a[len(a)/2:][::-1]
		
		for i in range(len(m)):
			s=abs(int(ord(m[i]))-int(ord(n[i])))
			c=c+s
		print(c)


for i in range(eval(input())):
	a=input()
	c=0
	for j in range(0,len(a)/2):
		c+=abs(ord(a[j])-ord(a[len(a)-1-j]))
	print(c)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(input())

while(n>0):
	s = input()
	s = list(s)
	c = 0
	for i in range(len(s)/2):
		if s[i] == s[len(s)-1-i]:
			continue
		else:
			c = c + abs(ord(s[i])-ord(s[len(s)-1-i]))
	print(c)
	n = n-1