코딩테스트/백준
백준 1759번 암호 만들기 python 파이썬
경미미
2022. 10. 5. 23:17
1759번: 암호 만들기
첫째 줄에 두 정수 L, C가 주어진다. (3 ≤ L ≤ C ≤ 15) 다음 줄에는 C개의 문자들이 공백으로 구분되어 주어진다. 주어지는 문자들은 알파벳 소문자이며, 중복되는 것은 없다.
www.acmicpc.net
from itertools import combinations
l, c = map(int, input().split())
a = sorted(input().split())
for s in combinations(a, l):
pw = []
vowel, consonant = 0, 0
for i in range(len(s)):
if s[i] in 'aeiou':
vowel += 1
else:
consonant += 1
pw += s[i]
if vowel >= 1 and consonant >= 2:
print(*pw)