둘만의 암호

최민수·2023년 2월 21일
0

알고리즘

목록 보기
3/94
# index 만큼 뒤의 알파벳으로 변환
def changeWord(word, basket, index):
    loc = basket.find(word) + index
    loc %= len(basket)

    return basket[loc]


def solution(s, skip, index):
    answer = ''

    # skip words를 제외한 알파벳 리스트 완성
    basket = "abcdefghijklmnopqrstuvwxyz"
    for item in skip:
        if basket.find(item) != -1:
            basket = basket.replace(item, '')

    for word in s:
        answer += changeWord(word, basket, index)

    return answer

출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges

profile
CS, 개발 공부기록 🌱

0개의 댓글