[Programmers] - 소수 만들기 (Level 1)


Summer/Winter Coding(~2018)
LEVEL : 1

문제 링크

nums = [1,2,7,6,4]
def solution(nums):

    from itertools import combinations

    sums = []
    for i in combinations(nums, 3):
        sums.append(sum(i))

    Primes = []
    for i in sums:
        p = True
        for j in range(2,round(i**(1/2)+1)):
            if i % j == 0:
                p = False

        if p ==True: Primes.append(i)


    return len(Primes)
solution(nums)
4

Comments