# 소수 찾기
fromitertoolsimportpermutationsdefprimeList(n):primeList=[True]*n# i=sqrt(maximum)까지 검사
m=int(n**0.5)foriinrange(2,m+1):ifprimeList[i]==True:forjinrange(i+i,n,i):primeList[j]=Falsereturn[iforiinrange(2,n)ifprimeList[i]==True]defsolution(numbers):answer=0numList=list(numbers)foriinrange(2,len(numbers)+1):pm=list(permutations(numbers,i))forjinpm:iflen(j)<=len(numbers):numList.append(''.join(j))# 정수형으로 바꿔주고, set으로 중복 제거
numList=list(set([int(r)forrinnumList]))ifnumList.count(1):numList.remove(1)ifnumList.count(0):numList.remove(0)primeL=primeList(max(numList)+1)foriinnumList:ifiinprimeL:answer+=1returnanswer