Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

57-xxubin04 #215

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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