Data house
[python] lv1. 시저암호 - 아스키코드 본문
728x90
문제
https://school.programmers.co.kr/learn/courses/30/lessons/12926
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제 전략
1. 아스키 코드의 사용법 알기 : ord(), chr()
2. 알파벳 숫자의 갯수 26개 사용하기
인상적인 풀이
def solution(s, n):
arr = ""
for i in s:
if i == ' ':
arr += " "
# 소문자일 경우
elif i.islower():
arr += chr((ord(i) - ord('a') + n) % 26 + ord('a'))
# 대문자일 경우
elif i.isupper():
arr += chr((ord(i) - ord('A') + n) % 26 + ord('A'))
return arr
참고자료
https://seongonion.tistory.com/126
[Python] 아스키코드 사용하기
아스키코드란? 미국정보교환표준부호(영어: American Standard Code for Information Interchange), 또는 줄여서 ASCII( /ˈæski/, 아스키)는 영문 알파벳을 사용하는 대표적인 문자 인코딩이다. 아스키는 컴퓨터와
seongonion.tistory.com
'Computer Knowledge > 코테 대비 오답노트' 카테고리의 다른 글
[python] lv.1 추억 점수 - ㅋㅋㅋㅋ한 줄 풀이 어이없어 (0) | 2023.09.22 |
---|---|
⭐️⭐️[python] lv.1 비밀지도 (0) | 2023.09.21 |
⭐️ [python] 예산 - 1단계지만 어려워 (0) | 2023.09.20 |
[python] 3진법 변환 - divmod(), int() (0) | 2023.09.20 |
[python] 평행 - itertools (0) | 2023.06.07 |