본문 바로가기

Programming/Programmers

[프로그래머스/Python] 소수찾기(소수/순열/중복제거)

from itertools import permutations

def isPrime(num):
    if num < 2:
        return False
    
    for i in range(2,num):
        if num%i==0: 
            return False
        
    return True
    
    
def solution(numbers):
    answer = []
    for k in range(1, len(numbers)+1):
        perlist = list(map(''.join, permutations(list(numbers), k)))
        for num in list(set(perlist)):
            if isPrime(int(num)): 
                answer.append(int(num))
        
    return len(set(answer))