forked from CBNU-Nnet/2022-algorithm-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3주차] : 허원일 - 오픈채팅방 lv.2 (CBNU-Nnet#60)
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
def solution(record): | ||
answer = [] | ||
uid_arch = {} # 유저아이디 : 닉네임 을 저장하는 딕셔너리 | ||
|
||
# 반복문을 돌며 기록 처리 | ||
for rec in record: | ||
rec_splited = rec.split() | ||
if (rec_splited[0] == 'Enter') or (rec_splited[0] =='Change'): | ||
uid_arch[rec_splited[1]] = rec_splited[2] | ||
|
||
# 반복문을 돌며 처리된 기록을 바탕으로 메시지 저장 | ||
for rec in record: | ||
rec_splited = rec.split() | ||
if rec_splited[0] == 'Enter': | ||
answer.append(f"{uid_arch[rec_splited[1]]}님이 들어왔습니다.") | ||
elif rec_splited[0] == 'Leave': | ||
answer.append(f"{uid_arch[rec_splited[1]]}님이 나갔습니다.") | ||
|
||
return answer |