목록분류 전체보기 (234)
honey_pot
보호되어 있는 글입니다.
보호되어 있는 글입니다.
Counter collections 모듈 리스트나 딕셔너리 안에 존재하는 원소의 개수를 세서 딕셔너리 자료형으로 반환한다. {'A':4} reduce functools 내장 모듈 데이터에 집계 함수를 반복해서 계산해줌 reduce(집계 함수, 순회 가능한 데이터[, 초기값]) 첫번째 인자는 accumulator, 두번째 인자는 현재값(current value) https://programmers.co.kr/learn/courses/30/lessons/42578?language=python3 코딩테스트 연습 - 위장 programmers.co.kr def solution(clothes): from collections import Counter from functools import reduce cnt =..
보호되어 있는 글입니다.
보호되어 있는 글입니다.
https://programmers.co.kr/learn/courses/30/lessons/42626 코딩테스트 연습 - 더 맵게 매운 것을 좋아하는 Leo는 모든 음식의 스코빌 지수를 K 이상으로 만들고 싶습니다. 모든 음식의 스코빌 지수를 K 이상으로 만들기 위해 Leo는 스코빌 지수가 가장 낮은 두 개의 음식을 아래와 같 programmers.co.kr from heapq import * def solution(scoville, K): answer = 0 heapify(scoville) while scoville[0] 1: mi1 = heappop(scoville) mi2 = heappop(scoville) heappush(scoville, mi1 + mi..
https://programmers.co.kr/learn/courses/30/lessons/42586 코딩테스트 연습 - 기능개발 프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 programmers.co.kr def solution(progresses, speeds): answer = [] cnt = 0 days = 0 while len(progresses): if (progresses[0] + days*speeds[0]) >= 100: progresses.pop(0) speeds.pop(0) cnt += 1 else: if cnt > 0 : answer.ap..
https://programmers.co.kr/learn/courses/30/lessons/12945 코딩테스트 연습 - 피보나치 수 피보나치 수는 F(0) = 0, F(1) = 1일 때, 1 이상의 n에 대하여 F(n) = F(n-1) + F(n-2) 가 적용되는 수 입니다. 예를들어 F(2) = F(0) + F(1) = 0 + 1 = 1 F(3) = F(1) + F(2) = 1 + 1 = 2 F(4) = F(2) + F(3) = 1 + 2 = 3 F(5) = F(3) + F(4) = programmers.co.kr def solution(n): answer = [0,1] for i in range(2, n+1): answer.append((answer[i-2] + answer[i-1])%1234567..