
1. 문제 2. 소스코드 import math def solution(brown, yellow): answer = [] all = brown + yellow for col in range(3, int(math.sqrt(all))+1): if all % col: continue row = all // col if (row-2) * (col-2) == yellow: return [row, col] 3. 고찰 1) 알고리즘 전체 카펫 격자 개수를 all에 담았다. 세로 < 가로 이기 때문에 세로에 대해 for문을 돌렸다. 가로에 대해서 돌리려면 루트(전체 격자개수) ~ 전체격자개수로 돌리면 된다. 가로, 세로의 최소 개수는 3이다. yellow의 상하좌우에 brown이 1줄씩 있기 때문. 세로col을 3~루트..

1. 문제 2. 소스코드 import math def solution(progresses, speeds): answer = [] now = 0 next = 0 daysleft = [math.ceil((100-progresses[i])/speeds[i]) for i in range(len(progresses))] print(daysleft) while next!=len(progresses): now = next next+= 1 count = 1 for i in range(now +1, len(progresses)): if daysleft[now] >= daysleft[i]: count += 1 next+= 1 else: break answer.append(count) return answer 3. 고찰 1..
1. 문제 programmers.co.kr/learn/courses/30/lessons/42626 코딩테스트 연습 - 더 맵게 매운 것을 좋아하는 Leo는 모든 음식의 스코빌 지수를 K 이상으로 만들고 싶습니다. 모든 음식의 스코빌 지수를 K 이상으로 만들기 위해 Leo는 스코빌 지수가 가장 낮은 두 개의 음식을 아래와 같�� programmers.co.kr 2. 소스코드 import heapq as hq def solution(scoville, K): hq.heapify(scoville) answer = 0 while True: first = hq.heappop(scoville) if first >= K: break if len(scoville) == 0: return -1 second = hq.hea..

1. 문제 2. 소스코드 import heapq def solution(scoville, K): answer = 0 heapq.heapify(scoville) # scoville을 min heap으로 만들기 while True: first = heapq.heappop(scoville) # 가장 작은 원소 pop if first >= K: # 가장 작은 원소의 스코빌지수 >= K이면 문제 종료 #print("answer= ", answer) return answer if not scoville: # scoville이 비었으면 더 이상 못 함 return -1 # -1 리턴 second = heapq.heappop(scoville) # 두번째로 작은 원소 pop new = first + 2*second # ..

1. 문제 programmers.co.kr/learn/courses/30/lessons/42583 코딩테스트 연습 - 다리를 지나는 트럭 트럭 여러 대가 강을 가로지르는 일 차선 다리를 정해진 순으로 건너려 합니다. 모든 트럭이 다리를 건너려면 최소 몇 초가 걸리는지 알아내야 합니다. 트럭은 1초에 1만큼 움직이며, 다리 길이�� programmers.co.kr 2. 소스코드 import collections DUMMY_TRUCK = 0 class Bridge(object): def __init__(self, length, weight): self._max_length = length self._max_weight = weight self._queue = collections.deque() self._c..

1. 문제 programmers.co.kr/learn/courses/30/lessons/42587 코딩테스트 연습 - 프린터 일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린�� programmers.co.kr 2. 소스코드-1 ( Python3 ) def solution(priorities, location): queue = [(i,p) for i,p in enumerate(priorities)] answer = 0 while True: cur = queue.pop(0) if any(cur[1] < q[1] for q in queue): queue.append(cur) ..

1. 문제 2. 소스코드 ( Python3 ) def search(priorities, next, cnt): index = next for i in range(cnt-1): index += 1 if index == cnt: index = 0 if priorities[next] < priorities[index]: next = index return next def solution(priorities, location): answer = 0 # 변수 next = 0 # 다음에 프린트할 문서 index cnt = len(priorities) # 전체 문서 개수 while True: # next 찾기 next = search(priorities, next, cnt) # 프린트 하기 answer += 1 if ..
- Total
- Today
- Yesterday
- umount
- 리눅스
- Ubuntu16.04
- python3
- roslaunch
- 원격 통신
- 포트인식문제
- C++
- 윈도우 복구
- 백준알고리즘
- 프로그래머스
- ROS
- HC-SR04
- sensehat
- set backspace
- 8자주행
- 우분투
- VirtualBox
- 코드리뷰
- 윈도우
- 초음파센서
- vue/cli
- Ubuntu20.04
- 아두이노 IDE
- Publisher
- Python
- subscriber
- Mount
- filesystem
- VMware
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |