"""
입출력 예시)
numbers = "17" -> 3
numbers = "011" -> 2
"""
from itertools import permutations
# 소수인지 판별
def is_prime_n(x):
if x < 2:
return False
for i in range(2, x):
if x % i == 0:
return False
return True
def solution(numbers):
answer = 0
num = []
for i in range(1, len(numbers)+1):
num.append(list(set(map(''.join, permutations(numbers, i)))))
per_list = list(set(map(int, set(sum(num, []))))) # 순열 리스트
for p in per_list:
if is_prime_n(p) == True:
answer += 1
return answer
순열 permutations() 사용
from itertools import permutations
permutations(iterable, r) # r: 뽑을 원소의 개수