728x90
SMALL
이건 배열 슬라이싱만 잘 활용한다면 쉬운 문제 :)
카카오 문제 재밌다 ㅎㅎㅎㅎㅎ 구웃
그리고 나는 dictionary라는 배열에 A ~ Z까지 넣어 초기화 해준 다음, index값에 접근하여 해당 값을 answer에 넣어주었다. !!
def solution(msg):
answer = []
dictionary = [chr(i) for i in range(65,91)]
w=0
for c in range(len(msg)+1):
current = msg[w:c]
if c ==len(msg):
answer.append(dictionary.index(current)+1)
break
wc = msg[w:c+1]
if wc not in dictionary:
dictionary.append(wc)
answer.append(dictionary.index(current)+1)
w=c
else:
continue
return answer
728x90
LIST
'취준시절 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 2018 KAKAO BLIND RECRUITMENT - [3차] 방금그곡 (0) | 2021.09.09 |
---|---|
[프로그래머스] 2018 KAKAO BLIND RECRUITMENT - [3차] 파일명 정렬 (0) | 2021.09.08 |
[프로그래머스] 소수찾기 - Python (0) | 2021.08.26 |
[프로그래머스] 위장 - Python (0) | 2021.08.11 |
[프로그래머스] 구명보트 - Python (0) | 2021.08.10 |