초간단 python BFS Breadth First Search 너비 우선 탐색
graph={ 1:[2,3], 2:[1,4,5,7], 3:[1,5,9], 4:[2,6], 5:[2,3,7,8], 6:[4], 7:[5,2], 8:[5], 9:[3], } def BFS(graph,root): visited=[] queue=[root] while queue:#while queue is not empty n = queue.pop(0) if n not in visited:#if n is not in visited list. visited.append(n)#put the n to the visited list. for i in graph[n]:#the numbers i connected with n if i not in visited:#i is not in visited list. queue.a..
Programmers Level 8 선입선출 스케줄링
def getCoreNumber(n, cores): time = 0 while n>0: for i in range(0,len(cores)): if time%cores[i]==0: #현재 시간 나누기 처리 시간의 나머지 n-=1 if n==0: return i+1 time+=1 print(getCoreNumber(6, [1, 2, 3])) print(getCoreNumber(22,[1,2,3,4,5]))