코-딩/프로그래머스

코-딩/프로그래머스

프로그래머스::신고 결과 받기

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/92334 난이도 : Lv.1 풀이 from collections import defaultdict def solution(id_list, report, k): mailCnt = {} for id in id_list: mailCnt[id] = 0 reportedPerson = {} for rpt in report: s, t = rpt.split(" ") if t not in reportedPerson: reportedPerson[t] = [s] elif s not in reportedPerson[t]: reportedPerson[t].append(s) for rp in reportedPerso..

코-딩/프로그래머스

프로그래머스::콜라츠 추측

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/12943 난이도 : Lv.1 풀이 def solution(num): answer = 0 while True: if num == 1: return answer if answer == 500: return -1 if num % 2 == 0: num = num / 2 elif num % 2 == 1: num = num * 3 + 1 answer += 1 양심상... 설마 이렇게 단순한 풀이를 원했을까...하는 마음에 다른 풀이를 고민해봤다.. 다른 풀이 def solution(num): for i in range(501): if num == 1: return i num = num/2 if num%..

코-딩/프로그래머스

프로그래머스::실패율

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42889 난이도 : Lv.1 풀이 def solution(N, stages): answer = {} totalUser = len(stages) # 총 유저수 for i in range(1, N+1): if(totalUser == 0): answer[i] = 0 else: answer[i] = stages.count(i)/totalUser totalUser -= stages.count(i) answer = dict(sorted(answer.items(), key=lambda x : x[1], reverse=True)) return list(answer.keys()) 다 풀고 나니까, 마지막에 ..

코-딩/프로그래머스

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

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/92341 난이도 : Lv.2 풀이 from collections import defaultdict import math def solution(fees, records): answer = [] inDict = dict() outDict = defaultdict(int) for re in records: time, carNo, div = re.split(" ") mTime = int(time.split(":")[0])*60 + int(time.split(":")[1]) # 분 환산 if(div == "IN"): inDict[carNo] = mTime elif(div == "OUT"): outD..

코-딩/프로그래머스

프로그래머스::개인정보 수집 유효기간

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/150370 난이도 : Lv.1 풀이 def solution(today, terms, privacies): answer = [] termsDict = {t.split(" ")[0] : int(t.split(" ")[1])*28 for t in terms} td = today.split(".") tdDays = 12*28*int(td[0]) + 28*int(td[1]) + int(td[2]) for i,p in enumerate(privacies): diff = termsDict[p[-1]] p = p[:-2] pDays = 12*28*int(p.split(".")[0]) + 28 * int(p..

코-딩/프로그래머스

프로그래머스::숫자 문자열과 영단어

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/81301 난이도 : Lv.1 풀이 def solution(s): if s.isdigit(): return int(s) numStr = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] for i in range(len(numStr)): s = s.replace(numStr[i], str(i)) return int(s)

힞뚜루마뚜루
'코-딩/프로그래머스' 카테고리의 글 목록 (2 Page)