Home

[프로그래머스] 의상

문제 from itertools import combinations def solution(clothes): answer = 1 dic = {} for i in clothes: if i[1] not in dic.keys(): dic[i[1]] = [i[0]] else: dic[i[1]].append(i[0]) for i in dic.keys(): answer*=(len(dic[i])+1) return answer - 1

Read more

[프로그래머스] 주차 요금 계산

문제 def solution(fees, records): answer = [] parking = {} minute = {} for record in records: time, car, action = record.split() if car not in minute: minute[car] = 0 for record in records: time, car, action = record.split() time = int(time[:2]) * 60 + int(time[3:5]) ...

Read more

[프로그래머스] 스킬트리

문제 def solution(skill, skill_trees): answer = 0 s = [] for i in skill_trees: for j in i: if j not in skill: i = i.replace(j, '') s.append(i) print(s) for i in s: if skill[:len(i)] == i: answer+=1 return answer

Read more

[프로그래머스] 더 맵게

문제 import heapq def solution(scoville, K): answer = 0 heapq.heapify(scoville) while True: if len(scoville) < 2: if scoville[0] >= K: return answer else: return -1 else: tmp1 = heapq.heappop(scoville) tmp2 = heapq.heappop(scoville) ...

Read more