Skip to content

Commit 7a7fb45

Browse files
author
hangyeol
committed
93차 2번 문제풀이
1 parent 67fcfd9 commit 7a7fb45

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

live9/test93/문제2/백한결.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(name):
2+
count = 0
3+
4+
for a in name:
5+
count += min(ord(a) - ord('A'), ord('Z') - ord(a) + 1)
6+
7+
min_move = len(name) - 1
8+
9+
for i in range(len(name)):
10+
next = i + 1
11+
while next < len(name) and name[next] == 'A':
12+
next += 1
13+
14+
move = min(i, len(name) - next) * 2 + max(i, len(name) - next)
15+
min_move = min(min_move, move)
16+
17+
count += min_move
18+
19+
return count
20+
21+
22+
print(solution("JEROEN"))

0 commit comments

Comments
 (0)