728x90
반응형
combinations 에 대해서 확실하게 사용할 수 있도록 하자.
from itertools import combinations
def isPrime(n):
if n==1 or n==0 :
return False
elif n>1:
for i in range(2,round(n/2)):
if n%i == 0:
return False
return True
def solution(nums):
answer = 0
combin = list(combinations(nums,3))
for arr in combin:
if isPrime(sum(arr)):
answer += 1
return answer728x90
반응형
'Job Wanted > 코테 - 프로그래머스' 카테고리의 다른 글
| [프로그래머스] 코딩테스트 입문 > 문자열 계산하기 (0) | 2022.11.15 |
|---|---|
| [프로그래머스] 코딩테스트 입문 > 직사각형 넓이 구하기 (0) | 2022.11.15 |
| [프로그래머스] 위클리 챌린지 > 부족한 금액 계산하기 (0) | 2022.11.11 |
| [프로그래머스] 월간 코드 챌린지 시즌2 > 약수의 개수와 덧셈 (0) | 2022.11.10 |
| [프로그래머스] 월간 코드 챌린지 시즌1 > 두 개 뽑아서 더하기 (0) | 2022.11.10 |
