반응형
1. 문제 설명
programmers.co.kr/learn/courses/30/lessons/42839
2. 풀이
from itertools import combinations,permutations
def solution(numbers):
count = 0
test_number = []
for i in range(len(numbers)):
case = list(set(map(''.join,permutations(numbers,i+1))))
for j, number in enumerate(case):
test_number.append(int(number))
test_number = list(set(test_number))
for i, number in enumerate(test_number):
if isPrime(number)== True:
count +=1
return count
def isPrime(x):
if x<2:
return False
else:
for i in range(2,x):
if x % i == 0:
return False
return True
728x90
반응형
'Study > Algorithm & Data structure' 카테고리의 다른 글
[프로그래머스] [완전탐색] 모의고사 (201103) (0) | 2020.11.05 |
---|---|
[프로그래머스][stack/queue] 탑 python (201104) (0) | 2020.11.05 |
[백준] (dp) 숨바꼭질 201101 (0) | 2020.11.03 |
[백준] (bfs) 숨바꼭질 201031 (0) | 2020.10.31 |
[프로그래머스] greedy 체육복 201030 (0) | 2020.10.30 |
댓글