Skip to content

Commit 8b08e1e

Browse files
committed
[BOJ] #1283. 단축키 지정 / 실버1 / 40분 / 힌트, 성공
1 parent be745b2 commit 8b08e1e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
6+
def setOptions(option):
7+
# 1. 각 단어의 첫 글자 우선 확인
8+
for i in range(len(option)):
9+
if option[i][0].upper() not in shortcut_key:
10+
shortcut_key.add(option[i][0].upper())
11+
option[i] = f"[{option[i][0]}]{option[i][1:]}"
12+
return option
13+
14+
# 2. 전체 단어의 모든 글자 중 아직 등록되지 않은 글자 탐색
15+
for i in range(len(option)):
16+
for j in range(len(option[i])):
17+
if option[i][j].upper() not in shortcut_key:
18+
shortcut_key.add(option[i][j].upper())
19+
option[i] = f"{option[i][:j]}[{option[i][j]}]{option[i][j + 1:]}"
20+
return option
21+
22+
# 3. 지정할 수 있는 단축키가 없는 경우
23+
return option
24+
25+
26+
N = int(input())
27+
shortcut_key = set()
28+
29+
for _ in range(N):
30+
option = input().split()
31+
result = setOptions(option)
32+
print(' '.join(result))

0 commit comments

Comments
 (0)