728x90 320x100 💻 하나씩 차곡차곡/프로그래머스 (Python)93 [프로그래머스/Lv.1/Python] 폰켓몬 def solution(nums): answer = 0 # 가져가 포켓몬의 갯수 mari = len(nums) / 2 # 포켓몬의 종류 type = len(set(nums)) if mari > type : return type else : return mari return answer 2024. 1. 10. [프로그래머스/Lv.1/Python] 의상 def solution(clothes): answer = 0 cntList = [] clotheslist = {} for n, t in clothes: if t in clotheslist: clotheslist[t].append(n) else: clotheslist[t] = [n] for cloth in clotheslist: cntList.append(len(clotheslist[cloth])) print(clotheslist, cntList) # 옷종류가 하나일 때 if len(cntList) == 1: return cntList[0] else : cnt = 1 for i in cntList: cnt *= i return sum(cntList) + cnt return answer 처음에 이렇게 구현했.. 2024. 1. 9. [프로그래머스/Lv.2/Python] 전화번호 목록 def solution(phone_book): answer = True phone_book.sort() for i in range(len(phone_book)-1): if len(phone_book[i]) < len(phone_book[i+1]): if phone_book[i + 1][:len(phone_book[i])] == phone_book[i]: answer = False break return answer 2024. 1. 8. [프로그래머스/Lv.1/Python/해시] 완주하지 못한 선수 def solution(participant, completion): # 정렬 participant.sort() completion.sort() for i in range(len(completion)): if participant[i] != completion[i]: return participant[i] return participant[-1] 아니 겁나 간단해보이는데 왜케 안풀리는 거임 진짜 별거 아닌걸로 개고생했네 진짜 하 자괴감 오져 2024. 1. 5. [프로그래머스/Lv.1/Python] [PCCP 기출문제] 1번 / 붕대 감기 def solution(bandage, health, attacks): maxHealth = health # 최대체력 저장 time = 0 # 현재시간 continueSuccess = 0 # 연속성공횟수 maxTime = attacks[-1][0] # 마지막 공격시간 attackDict = {} # 공격시간, 피해량 dic for attack in attacks: attackDict[attack[0]] = attack[1] while time maxHealth: health = maxHealth time += 1 # 시간증가 return health 2024. 1. 4. [프로그래머스/python/Lv1] 개인정보 수집 유효기간 from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta def solution(today, terms, privacies): answer = [] for index,i in enumerate(privacies): privaciesList = i.split(" ") for j in terms: termsList = j.split(" ") if privaciesList[1] == termsList[0]: todayDate = datetime.strptime(today, "%Y.%m.%d") privaciesDate = datetime.strptime(privaciesList[0], "%Y.%m.%d") .. 2024. 1. 1. 이전 1 2 3 4 5 6 ··· 16 다음 728x90 320x100