Skip to content

Commit af91a58

Browse files
committed
97차 2번 문제풀이
1 parent 8a93371 commit af91a58

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

live9/test97/문제2/백유진.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def solution(name):
2+
answer = 0
3+
4+
min_cursor = len(name) - 1
5+
6+
for idx, alphabet in enumerate(name):
7+
answer += min(ord(alphabet) - 65, 91 - ord(alphabet))
8+
9+
end = idx+1
10+
while end < len(name) and name[end] == 'A':
11+
end += 1
12+
min_cursor = min(min_cursor, idx*2 + len(name)-end, (len(name)-end)*2 + idx)
13+
14+
answer += min_cursor
15+
16+
return answer

0 commit comments

Comments
 (0)