from itertools import permutations
def solution(numbers):
answer = 0
answer_list = {}
checkList = []
for i in range(len(numbers) + 1):
test = list(permutations(numbers, i))
for j in range(len(test)):
temp = list(test[j])
temp1 = ''.join(i for i in temp)
if temp1 != '':
if int(temp1) != 0:
answer_list[int(temp1)] = int(temp1)
checkList = answer_list.keys()
answer = checkPrime(checkList)
return answer
def checkPrime(checkList):
count = 0
for check in checkList:
temp = prime(check)
count += temp
return count
def prime(check):
if check == 0 | check == 1:
return 0
for i in range(2, check//2+1):
if check % i == 0:
return 0
return 1
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[파이썬][프로그래머스] 완전탐색 피로도 (0) | 2022.11.29 |
---|---|
[파이썬][프로그래머스] 완전탐색 카펫 (0) | 2022.11.28 |
[파이썬][프로그래머스] 완전탐색 모의고사 (0) | 2022.11.25 |
[파이썬][프로그래머스] 완전탐색 최소직사각형 (0) | 2022.11.24 |
[파이썬][프로그래머스] 정렬 H-Index (0) | 2022.11.23 |
댓글