[백준] #10809 알파벳 찾기 python
2022. 12. 22. 11:05
https://www.acmicpc.net/problem/10809
조금 더 깔끔하게 풀 수 있는 방법을 알아보자.
num_l = input()
char_l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
cnt = 0
char_dict = {}
for i in num_l:
if i in char_dict:
cnt += 1
continue
char_dict[i] = cnt
cnt += 1
for i in char_dict:
for j in range(len(char_l)):
if char_l[j] == i:
char_l[j] = str(char_dict[i])
for i in range(len(char_l)):
if not str(char_l[i]).isdigit():
char_l[i] = str(-1)
print(' '.join(char_l))
'Programming > Algorithm' 카테고리의 다른 글
[백준] #1157 문자열 upper, lower python (0) | 2022.12.22 |
---|---|
[백준] #11720 문자열 반복 python (0) | 2022.12.22 |
[백준] #11720 필요없는 input 날리기 python (1) | 2022.12.22 |
[백준] #1065 한수 python (0) | 2022.12.21 |
[백준] #4673 셀프 넘버 python (0) | 2022.12.21 |