일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- level4
- python
- 파이썬
- Stack
- 완전탐색
- programmers
- hackerrank
- 코딩
- counter
- time complexity
- join
- mysql
- lambda
- 조합
- Level2
- 프로그래머스
- itertools
- lv4
- coding test
- coding
- Growth hacking
- sql
- Queue
- collections
- tableau
- 코테
- AARRR
- cte
- import re
- 코딩테스트
Archives
- Today
- Total
ror_coding
[Programmers] 둘만의 암호 - 155652 본문
728x90
특정 alphabet을 건너 뛰게 하는 방법을 a~z를 직접 입력하여 skip할 alphabet을 빼준다.
Question
두 문자열 s와 skip, 그리고 자연수 index가 매개변수로 주어질 때 위 규칙대로 s를 변환한 결과를 return하도록 solution 함수를 완성해주세요.
Code (After)
def solution(s, skip, index):
alpha = [i for i in 'abcdefghijklmnopqrstuvwxyz' if i not in skip]*5
return ''.join([alpha[alpha.index(i) + index] for i in s])
Code (Before)
def solution(s, skip, index):
answer = ''
alpha = [i for i in 'abcdefghijklmnopqrstuvwxyz' if i not in skip]
for al in s:
answer += alpha[(alpha.index(al) + index) % len(alpha)]
return answer

now me
On my github
728x90
'Coding Test > Python' 카테고리의 다른 글
[Programmers] 숫자 짝꿍 - 131128 (0) | 2024.10.22 |
---|---|
[Programmers] 체육복 - 42862 (1) | 2024.10.17 |
[Programmers] 대충 만든 자판 - 160586 (0) | 2024.10.14 |
[Programmers] [1차] 다트 게임 - 17682 (1) | 2024.10.13 |
[Programmers] 옹알이 (2) - 133499 (0) | 2024.10.13 |