1. 문제
https://programmers.co.kr/learn/courses/30/lessons/12977
2. 풀이
import math
from itertools import combinations
def is_sosu(number):
for i in range(2, int(math.sqrt(number))+1):
if number % i == 0:
return False
return True
def solution(nums):
answer = 0
for x in list(combinations(nums, 3)):
if is_sosu(sum(x)):
answer += 1
return answer
PREVIOUS[프로그래머스] x만큼 간격이 있는 n개의 숫자 풀이