-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from xxubin04/57-xxubin04
57-xxubin04
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
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
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,41 @@ | ||
def msg(act, name): | ||
if act == "Enter": | ||
return name+"λμ΄ λ€μ΄μμ΅λλ€." | ||
else: # act == "Leave" | ||
return name+"λμ΄ λκ°μ΅λλ€." | ||
|
||
|
||
def solution(record): | ||
answer = [] | ||
users = {} | ||
|
||
for r in record: | ||
splitRecord = r.split() | ||
command = splitRecord[0] | ||
userId = splitRecord[1] | ||
|
||
if command == "Leave": | ||
if userId in users: | ||
users[userId].append((command, "")) | ||
else: | ||
users[userId] = [(command, "")] | ||
else: | ||
if userId in users: | ||
users[userId].append((command, splitRecord[2])) | ||
else: | ||
users[userId] = [(command, splitRecord[2])] | ||
|
||
nicknames = {} | ||
|
||
for userId, action in users.items(): | ||
for command, name in reversed(action): | ||
if command == "Enter" or command == "Change": | ||
nicknames[userId] = name | ||
break | ||
|
||
for output in record: | ||
splitOutput = output.split() | ||
if splitOutput[0] != "Change": | ||
answer.append(msg(splitOutput[0], nicknames[splitOutput[1]])) | ||
|
||
return answer |