jm_p_op
모의고사 해설 4. 둘만의 암호 본문
https://school.programmers.co.kr/learn/courses/30/lessons/155652
def solve_key(skip_list, _char, index): #문자열을 다섯개더할지 일곱개더할지..
n = 0
_char = ord(_char)
while True:
_char += 1
if _char > 122:
_char -= 26
if _char not in skip_list:
n += 1
if n == index:
break
return chr(_char)
def solution(s, skip, index):
skip_list = list(map(lambda x: ord(x), skip))
s_list = list(map(lambda x: solve_key(skip_list, x,index), s))
answer = ''.join(s_list)
return answer
skip_list=제외 할 문자 아스키코드열
solve_key(제외 할 문자,영단어,이동할갯수)
- while문에서 제외할거 무시하면서 이동후 다이동하면 나오기
ord(): 아스키 코드로 바꾸기
str():아스키 코드에서 문자로 바꾸기
같이 한 팀원
'수학 > 알고리즘' 카테고리의 다른 글
모의고사 해설 4. 실패율-코딩 줄이기 (0) | 2023.04.21 |
---|---|
모의고사 해설 4. 실패율 (0) | 2023.04.21 |
모의고사 해설 3. 방의갯수 (0) | 2023.04.18 |
.py 알고리즘 모의고사 코딩리뷰 + 수정 (0) | 2023.04.05 |
모의고사 해설 3. array (0) | 2023.04.03 |