본문 바로가기
반응형

프로그래머스234

(Python/LV2)이모티콘 할인 행사 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/150368 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: from itertools import product def solution(users, emoticons): res = [0, 0] for discounts in product((40,30,20,10), repeat = len(emoticons)): # print(discounts) result = [0, 0] # 이모티콘 판매액 for user_discount, user_m.. 2023. 1. 17.
(Python/LV2)개인정보 수집 유효기간 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/150370 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(today, terms, privacies): dic = dict() for i in terms: Alpha, mon = i.split(" ") dic[Alpha] = mon y,m,d = map(int,today.split(".")) result = [] for idx,i in enumerate(privacies,start=1): date, alpah .. 2023. 1. 7.
(Python/Lv2)마법의 엘리베이터 문제 출처:https://school.programmers.co.kr/learn/courses/30/lessons/14865 풀이: 틀린풀이 def solution(storey): arr =[ int(i) for i in str(storey)] count = 0 while len(arr) > 0: number = arr.pop() if number > 5: count += 10 - number next_number = arr.pop() next_number += 1 arr.append(next_number) else: count += number return count 38.5 / 100 def solution(storey): arr =[ int(i) for i in str(storey)] count =.. 2023. 1. 1.
(Python/LV2) 테이블 해시 함수 문제 출처: 풀이: def solution(data, col, row_begin, row_end): x = sorted(data, key =lambda x:(x[col-1],-x[0])) res = [] while row_begin 2022. 12. 26.
(Python/LV1) 크기가 작은 부분 문자열 문제 출처:https://school.programmers.co.kr/learn/courses/30/lessons/147355 풀이: def solution(t, p): list = [] x,y = 0,len(p) while len(t)-x >= y : list.append(t[x:x+y]) x += 1 return len([i for i in list if int(i) 2022. 12. 26.
(Python/LV2) 디펜스 게임 출처: https://school.programmers.co.kr/learn/courses/30/lessons/142085 문제 풀이: import heapq def solution(n, k, enemy): list = [] res = 0 count = 0 for i in enemy: res += i # 일단 막고봄 if res > 밑에서 최댓 값 비교 count += 1 elif k > 0: # 이제 필살기를 써서 막을때 k -= 1 # k를 1 깎고 res += heapq.heappushpop(list,-i) # 가장 높은값과 에너미와 비교해서 높은거를 k를 막고 낮은거를 다시 집어넣은 count +=1 else: break return count 2022. 12. 18.
반응형