본문 바로가기

전체 글57

실패율 def solution(N, stages): answer = [] result = [] for step in range(1, N+1): fail = 0 play = 0 for stage in stages: if stage == step: fail += 1 play += 1 elif stage > step: play+=1 else: pass if play == 0: result.append((step, 0)) else: result.append((step, fail/play)) result.sort(key = lambda x : (-x[1], x[0])) for step in result: answer.append(step[0]) return answer 문제풀이 특별한 알고리즘이 필요하지 않은 문제였다... 2021. 6. 3.
ReferenceError: primordials is not defined 발생 과정 토이 프로젝트인 Drello의 UI를 개선하기 위해 Semantic UI를 이용하기로 했다. Semantic UI를 설치하는 과정에서 ReferenceError: primordials is not defined 오류가 발생했다. 명령어 npm install semantic-ui --save 오류 해당 오류는 node.js의 버젼이 Semantic UI를 허용하지 않기 때문에 발생했다. 따라서 node.js의 버젼을 다운그레이드해야 해결된다. 해결법 나는 nvm window를 설치하여 다른 버젼 node.js를 설치하여 사용할 수 있게 했다. 본래 내가 사용하는 버젼은 v14이고 다운그레이드한 버젼은 v10이다. 출처 https://github.com/coreybutler/nvm-windows .. 2021. 6. 3.
오픈채팅방 문제풀이 def solution(record): answer = [] id_dict = {} systems = [] for log in record: logs = log.split() if logs[0] == "Enter": id_dict[logs[1]] = logs[2] systems.append([logs[1], "님이 들어왔습니다."]) elif logs[0] == "Leave": systems.append([logs[1], "님이 나갔습니다."]) else: id_dict[logs[1]] = logs[2] for system in systems: answer.append(id_dict[system[0]]+system[1]) return answer 알고리즘 특별한 알고리즘이 필요한 문제는 아니다... 2021. 6. 1.
게임 맵 최단거리 문제풀이 효율성 실패 import copy def remove_values_from_list(the_list, val): return [value for value in the_list if value != val] def move(my_point, maps, y_len, x_len, count): count += 1 time = 0 counts= [] maps[my_point[0]][my_point[1]] = 0 new_maps = copy.deepcopy(maps) if my_point[0] == y_len-1 and my_point[1] == x_len-1: return count if(my_point[0] != 0 and maps[my_point[0]-1][my_point[1]] != 0): ti.. 2021. 6. 1.