Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 데이콘
- 맥북
- 파이썬
- 편스토랑
- Kaggle
- 더현대서울 맛집
- 프로그래머스 파이썬
- AI 경진대회
- leetcode
- 백준
- Baekjoon
- 자연어처리
- dacon
- ChatGPT
- SW Expert Academy
- 금융문자분석경진대회
- hackerrank
- Git
- github
- ubuntu
- programmers
- 프로그래머스
- 편스토랑 우승상품
- gs25
- 코로나19
- Docker
- 캐치카페
- 우분투
- PYTHON
- Real or Not? NLP with Disaster Tweets
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 6841번 : I Speak TXTMSG (Python) 본문
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 I Speak TXTMSG 입니다.
6841번: I Speak TXTMSG
The program will output text immediately after each line of input. If the input is one of the phrases in the translation table, the output will be the translation; if the input does not appear in the table, the output will be the original word. The transla
www.acmicpc.net
👨🏻💻 문제 풀이

Short Form 을 Key 로 Translation 을 Value 로 하는 Dictionary 를 만들었습니다.
msg_map = {
"CU": "see you",
":-)": "I’m happy",
":-()": "I’m unhappy",
";-)": "wink",
":-P": "stick out my tongue",
"(~.~)": "sleepy",
"TA": "totally awesome",
"CCC": "Canadian Computing Competition",
"CUZ": "because",
"TY": "thank-you",
"YW": "you’re welcome",
"TTYL": "talk to you later"
}
입력 받은 메세지가 위에서 만든 Dictionary 에 존재하면 입력 받은 메세지를 Key 로 하여 Value 를 꺼내옵니다.
if msg in msg_map:
msg = msg_map[msg]
존재하지 않으면 그냥 입력 받은 메세지를 그대로 출력하도록 하였습니다.
👨🏻💻 코드 ( Solution )
def i_speak_txtmsg(msg):
msg_map = {
"CU": "see you",
":-)": "I’m happy",
":-()": "I’m unhappy",
";-)": "wink",
":-P": "stick out my tongue",
"(~.~)": "sleepy",
"TA": "totally awesome",
"CCC": "Canadian Computing Competition",
"CUZ": "because",
"TY": "thank-you",
"YW": "you’re welcome",
"TTYL": "talk to you later"
}
if msg in msg_map:
msg = msg_map[msg]
return msg
if __name__ == "__main__":
while True:
try:
msg = input()
except EOFError:
break
print(i_speak_txtmsg(msg=msg))
GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 27522번 : 카트라이더: 드리프트 (Python) (0) | 2023.03.10 |
---|---|
[BaekJoon] 27866번 : 문자와 문자열 (Python) (0) | 2023.03.09 |
[BaekJoon] 26264번 : 빅데이터? 정보보호! (Python) (0) | 2023.03.07 |
[Programmers] 바탕화면 정리 (Python) (0) | 2023.03.06 |
[Programmers] 가위 바위 보 (Python) (0) | 2023.03.05 |
Comments