Skip to content

Commit

Permalink
Merge pull request #215 from xxubin04/57-xxubin04
Browse files Browse the repository at this point in the history
57-xxubin04
  • Loading branch information
9kyo-hwang authored Sep 15, 2024
2 parents 65f6537 + 0ce1894 commit febe963
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xxubin04/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@
| 53μ°¨μ‹œ | 2024.07.08 | DP | <a href="https://www.acmicpc.net/problem/2193">[2193]이친수 </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/200 |
| 54μ°¨μ‹œ | 2024.07.11 | Tree | <a href="https://www.acmicpc.net/problem/1991">[1991]트리 순회 </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/203 |
| 55μ°¨μ‹œ | 2024.07.29 | μ •λ ¬ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42747?language=python3">[Programmers]H-Index </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/208 |
| 56μ°¨μ‹œ | 2024.08.05 | κ΅¬ν˜„ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/17677#">[2018 KAKAO BLIND]λ‰΄μŠ€ ν΄λŸ¬μŠ€ν„°λ§ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/211 |
| 56μ°¨μ‹œ | 2024.08.05 | κ΅¬ν˜„ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/17677#">[2018 KAKAO BLIND]λ‰΄μŠ€ ν΄λŸ¬μŠ€ν„°λ§ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/211 |
| 57μ°¨μ‹œ | 2024.08.08 | Hash | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42888">[2019 KAKAO BLIND]μ˜€ν”ˆμ±„νŒ…λ°© </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/215 |
41 changes: 41 additions & 0 deletions xxubin04/ν•΄μ‹œλ§΅/μ˜€ν”ˆμ±„νŒ…λ°©.py
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

0 comments on commit febe963

Please sign in to comment.