Coding - Algo/python
[백준] 1759번:암호 만들기 (python 파이썬)
jainn
2021. 4. 20. 17:18
728x90
문제
풀이 및 소스코드
입력받은 알파벳을 정렬해준 후,
combinations를 통해 경우의 수를 만들어주고 자음 모음의 개수만 카운트해서 조건에 맞다면 출력해주면 된다.
import sys
from itertools import combinations
input = sys.stdin.readline
l, c = map(int, input().split())
alph = list(map(str, input().split()))
alph.sort()
comb = combinations(alph, l)
moum = ['a', 'e', 'i', 'o', 'u']
res = []
for c in comb:
j = 0
m = 0
for i in range(l):
if c[i] in moum:
m += 1
else:
j += 1
if m>=1 and j>=2:
print(''.join(c))
반응형