需要考虑顺时针与逆时针转换的数字大小,并要在输入的string前加上"a"
________________________________________________________________
需要使用python的ord函数——
ord()函数是chr()函数(对于8位的ASCII字符串)或unichr()函数(对于Unicode对象)的配对函数,它以一个字符(长度为1的字符串)作为参数,返回对应的ASCII数值,或者Unicode数值,如果所给的Unicode字符超出了你的Python定义范围,则会引发一个TypeError的异常。line = raw_input()
line = "a" + line
real_distance = 0
total_distance = 0
for i in range(1,len(line)):
distance1 = abs(ord(line[i]) - ord(line[i-1]))
distance2 = 26 - distance1
if distance1 < distance2:
real_distance = distance1
else:
real_distance = distance2
total_distance += real_distance
print total_distance