[백준] 1759: 암호만들기

JIN·2021년 10월 27일
0

조합

itertools 패키지의 combinations 라이브러리를 사용했습니다.

문제풀이 전략
1. l의 길이의 조합을 password 리스트에 저장한다.
2. 모음이 1개 이상, 자음이 2개 이상이므로 가능한 조합에서 모음의 개수를 센다.
(모음리스트는 vowel 임)
3. 모음의 개수가 1개 이상 , l-2개 이하이면 ''.join으로 출력한다.

from itertools import combinations
from collections import Counter
l, c = map(int, input().split())
password = list(input().split())
password.sort()
# print(password)
vowel = ['a', 'e', 'i', 'o', 'u']
for i in list(combinations(password, l)):
	count = 0
	for j in i:
		if j in vowel:
			count += 1
	if count >= 1 and count <= l-2:
		print(''.join(i))
profile
배우고 적용하고 개선하기

0개의 댓글

관련 채용 정보