def solution(records): users = {} cmd = {"Enter": "님이 들어왔습니다.", "Leave": "님이 나갔습니다."} for record in records: strSplit = record.split() if strSplit[0] == 'Enter': users[strSplit[1]] = strSplit[2] elif strSplit[0] == 'Change': users[strSplit[1]] = strSplit[2] output = [] for record in records: strSplit = record.split() if strSplit[0] != "Change": output.append('{}{}'.format(users[strSplit[1]], cmd[strSplit[0]])) return output
'Computer Science > 알고리즘 ( Algorithm )' 카테고리의 다른 글
Codility - Nesting (0) | 2019.03.11 |
---|---|
Codility - CyclicRotation (0) | 2019.03.11 |
Codility - Binary gap (0) | 2019.03.11 |
python string 다루기 (0) | 2019.01.01 |
[python] list 가지고 놀기 (0) | 2018.12.22 |