Source Code
import math

s = input()
s.strip()
size = len(s)
count = 0
mini = 100000
base = None

for i in s:
    count = 0
    base = i
    for j in s:
        diff = ord(base) - ord(j)
        count = count + abs(diff)
    if mini > count:
        mini = count

print(mini)
Copy
Palindrome Substrings jester
Python 3
1006 ms
4.2 MB
Time Limit Exceeded