Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 서울로인
- 송도 오마카세
- 이색데이트
- m1000RR
- 청키파이
- 가성비 오마카세
- 영등포 가볼만한 곳
- 영종도디저트
- 산정호수 한화리조트
- 글로우펏
- 바다앞꼬막집
- 책
- 현백 디저트
- 마살라 커리
- 남양주 여행지
- 중국
- 룸식당
- 을왕리데이트
- 정글만리
- 서울역 상견례
- 구읍뱃터맛집
- 구읍뱃터디저트
- 포천 가볼만한 곳
- 포천 관광지
- 조정래
- 서빙로봇
- 서울 부모님과 식사
- 차덕분
- 영종도맛집
- 인천맛집
Archives
- Today
- Total
ISTP의 간단명료 블로그
[프로그래머스] 기능개발 / 조건이 자연수인 경우 반영하기! 본문
문제

풀이
import math
def solution(progresses, speeds):
answer = []
cnt = 0
n=math.ceil((100-progresses[0])/speeds[0])
for i in range(len(progresses)):
if progresses[i]+speeds[i]*n >= 100:
cnt += 1
else:
answer.append(cnt)
n = math.ceil((100-progresses[i])/speeds[i])
cnt = 1
answer.append(cnt)
return answer
다른사람 풀이
from math import ceil
def solution(progresses, speeds):
daysLeft = list(map(lambda x: (ceil((100 - progresses[x]) / speeds[x])), range(len(progresses))))
count = 1
retList = []
for i in range(len(daysLeft)):
try:
if daysLeft[i] < daysLeft[i + 1]:
retList.append(count)
count = 1
else:
daysLeft[i + 1] = daysLeft[i]
count += 1
except IndexError:
retList.append(count)
return retList
느낀점
- 테스트 케이스 2번이 안 풀렸었는데 n(배포일자)가 자연수라는 것을 간과해서였다.
- 남은 작업량 / 작업속도 👉 2.5일인 경우 3일째에 배포하므로 math.ceil로 값을 올림해야 함
'풀다' 카테고리의 다른 글
| [프로그래머스] 더 맵게 / python 힙 자료구조 모듈 heapq (0) | 2023.06.21 |
|---|---|
| [프로그래머스] 프로세스 / 스택, 큐 / any, all (0) | 2023.06.18 |
| [프로그래머스] 완주하지 못한 선수 / 해시, Counter (0) | 2023.06.13 |
| [프로그래머스] 문자열 밀기 / find 함수 (0) | 2023.06.11 |
| [프로그래머스] 로그인 성공? / := 바다코끼리 연산자, 딕셔너리 get (0) | 2023.06.10 |