둘만의 암호 - Lv.1

송다은·2024년 10월 18일
from collections import deque
def solution(s, skip, index):
    answer = ''
    alpha= ['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']
    alpha_list = deque([i for i in alpha if i not in skip])
    for i in s:
        temp = alpha_list.index(i)
        alpha_list.rotate(-index)
        answer += alpha_list[temp]
    return answer

스스로 작성하고 맞춘 문제라 효율성이 떨어질 수 있다...
그래도 이제 라이브러리도 쓸 줄 아는 것 같고 어떻게 풀지 각이 잡히는 것 같다 ㅎㅎ
(물론 lv2 부터는 잘 안됨;;)

keypoint

  • skip에 해당하는 알파벳은 버리고, deque의 rotate를 사용하여 인덱스의 값만큼 이동해준 후 저장해둔 원래의 인덱스의 값을 가져온다
profile
Anomaly Detection, AI Security, Multimodal

0개의 댓글