Programming/Python & Data Structures
[Baekjoon/Python3] 5218번 알파벳 거리
HooNeee
2020. 12. 5. 20:54
[Baekjoon/Python3] 5218번 알파벳 거리
5218번: 알파벳 거리
첫째 줄에 테스트 케이스의 수 (< 100)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 두 단어가 공백으로 구분되어져 있다. 단어의 길이는 4보다 크거나 같고, 20보다 작거나 같으며, 알
www.acmicpc.net
t = int(input())
alp = [chr(i) for i in range(65, 91)]
for i in range(t):
res = []
x, y = input().split()
for j in range(len(x)):
if alp.index(y[j]) >= alp.index(x[j]):
res.append(alp.index(y[j]) - alp.index(x[j]))
elif alp.index(y[j]) < alp.index(x[j]):
res.append((alp.index(y[j]) + 26) - alp.index(x[j]))
print('Distances:', *res)