최대 1 분 소요

Python

from itertools import permutations
def is_prime_number(a):
    if(a<2):
        return False
    for i in range(2,a):
        if(a%i==0):
            return False
        
    return True
    
def solution(numbers):
    answer = 0
    temp = []
    for i in range(1, len(numbers) + 1):
        permutation = permutations(numbers, i)
        for j in permutation:
            temp.append(int(''.join(j)))
    for t in set(temp):
        if is_prime_number(t):
            answer += 1
            
    return answer

댓글남기기