728x90
320x100
from itertools import combinations
def solution(nums):
answer = 0
numList = list(combinations(nums,3))
sosuCnt = 0
for i in numList:
sumNum = sum(i)
for j in range(1, sumNum+1):
if sumNum % j == 0:
sosuCnt += 1
if sosuCnt == 2:
answer += 1
sosuCnt = 0
return answer
- 1. 중복이 불가능하고 순서가 있는 함수인 combinations를 사용하여 3가지 수의 리스트를 만들어 줌
- 2. 3가지의 합의 소수를 판별하고 소수인 경우 answer 의 카운트를 올려준다.
728x90
320x100
'💻 하나씩 차곡차곡 > 프로그래머스 (Python)' 카테고리의 다른 글
[프로그래머스/python/Lv1] 다트 게임 (1) | 2023.12.24 |
---|---|
[프로그래머스/python/Lv1] 실패율 (2) | 2023.12.23 |
[프로그래머스/python/Lv1] 두 개 뽑아서 더하기 (0) | 2023.12.22 |
[프로그래머스/python/Lv1] [1차] 비밀지도 (0) | 2023.12.21 |
[프로그래머스/python/Lv1] 숫자 문자열과 영단어 (2) | 2023.12.20 |