본문 바로가기
반응형

프로그래머스/2단계108

(Python/LV2) 압축 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/17684 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(scoville, K): sorted(scoville) count = 0 while min(scoville) < int(K): if scoville[0] < int(K) : x = scoville.pop(0) y = scoville.pop(0) scoville.insert(0, x + (2*y)) count += 1 return count 맞는 풀이 같지.. 2022. 9. 27.
(Python/LV2)주차 요금 계산 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/92341 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: import math def get_fee(time, fees): return fees[1] + math.ceil(max(0, (time - fees[0])) / fees[2]) * fees[3] def solution(fees, records): parking = {} total = {} for record in records: time, car, status = record... 2022. 9. 27.
(Python/LV2)[1차] 뉴스 클러스터링 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/17677 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: from collections import Counter def solution(str1, str2): result1 = [str1[i:i + 2].upper() for i in range(len(str1) - 1) if str1[i : i+2].isalpha()] result2 = [str2[i:i + 2].upper() for i in range(len(str2) - 1) if.. 2022. 9. 27.
(Python/LV2) 전화번호 목록 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/42577 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이과정: def solution(phone_book): phone_book.sort() set = { i for i in phone_book} for i in range(1,len(phone_book)): if set[i-1] in set[i]: return False return True 이렇게 하려했는데 set 함수는 슬라이싱이 안됨 def solution(phone_book):.. 2022. 9. 26.
(Python/LV2)프린터 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/42587 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: any (iterable) 함수는 인자로 받은 반복가능한 자료형(iterable)중 단 하나라도 참이 있으면 True를 반환하는 함수 def solution(priorities, location): list = [(x,y) for x,y in enumerate(priorities)] answer = 0 while True: now = list.pop(0) # 하나 빼줌 if a.. 2022. 9. 26.
(Python/LV2)기능개발 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/42586 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: # 27.3점 받은 코드 def solution(progresses, speeds): list = [] for x,y in zip(progresses, speeds): count = 0 while x = 100: list.append([x,count]) result = [True] for i in range(1,len(list)): result.append(list[i-1][1].. 2022. 9. 26.
반응형