[Python / 프로그래머스] 없는 숫자 더하기 def solution(numbers): answer = 0 lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in numbers: if i in lst: answer += i else: continue return (45 - answer) Language/Python 2022.04.25
[Python / 프로그래머스 level 2] JadenCase 문자열 만들기 def solution(s): answer = '' s = s.split(' ') for i in range(len(s)): s[i] = s[i].capitalize() answer = ' '.join(s) return answer Language/Python 2021.08.23
[Python / 프로그래머스 level 2] 올바른 괄호 def solution(s): stack = [] for i in s: if i == '(': stack.append(i) else: if stack == []: return False else: stack.pop() return stack == [] Language/Python 2021.08.20
[Python / 프로그래머스 level 2] 124 나라의 숫자 def solution(n): answer = '' while n: n, n2 = divmod(n, 3) answer = "412"[n2] + answer if not n2: n -= 1 return answer Language/Python 2021.08.19
[Python / 프로그래머스 level 2] 소수 찾기 from itertools import permutations def solution(numbers): num_list = [] for i in range(1, len(numbers)+1): test_list = permutations(numbers, i) for j in test_list: num_list.append(int("".join(j))) num_list = set(num_list) if 0 in num_list: num_list.remove(0) if 1 in num_list: num_list.remove(1) answer = len(num_list) for i in num_list: if i != 2: for j in range(2, int(i**0.5)+1): if i % j == 0: .. Language/Python 2021.08.18
[Python / 프로그래머스 level 2] 전화번호 목록 def solution(phone_book): phone_book.sort() for a,b in zip(phone_book, phone_book[1:]): if b.startswith(a): return False return True Language/Python 2021.08.17
[Python / 프로그래머스 level 2] 위장 def solution(clothes): closet = {} result = 1 for i in clothes: key = i[1] val = i[0] if key in closet: closet[key].append(val) else: closet[key] = [val] for key in closet.keys(): result = result * (len(closet[key]) + 1) return result - 1 Language/Python 2021.08.16
[Python / 프로그래머스 level 2] 기능개발 import math def solution(progresses, speeds): answer = [] progresses = [math.ceil((100-a)/b) for a, b in zip(progresses, speeds)] a = 0 for i in range(len(progresses)): if progresses[a] Language/Python 2021.08.13
[Python / 프로그래머스 level 2] 더 맵게 import heapq def solution(scoville, K): answer = 0 heapq.heapify(scoville) while scoville[0] Language/Python 2021.08.11
[Python / 프로그래머스 level 2] 다음 큰 숫자 def solution(n): a = bin(n).count('1') for i in range(n+1,1000001): if bin(i).count('1') == a: return i Language/Python 2021.08.10