Skip to content

Commit 6c9f2e2

Browse files
committed
[BOJ] #1759.암호 만들기 / 골드5 / 30(O)
1 parent c65e44c commit 6c9f2e2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"github.copilot.enable": {
3+
"*": false,
4+
"plaintext": false,
5+
"markdown": false,
6+
"scminput": false
7+
}
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
input = sys.stdin.readline
3+
from itertools import combinations
4+
5+
L, C = map(int, input().split())
6+
chars = input().split()
7+
chars.sort() # 오름차순 정렬
8+
9+
candidates = list(combinations(chars, L)) # L개 고르는 모든 조합을 생성
10+
11+
# 조건에 맞는 조합 필터링
12+
# 조건: 모음 >= 1개, 자음 >= 2개
13+
vowels = set('aeiou')
14+
15+
for comb in candidates:
16+
vowel_count = 0
17+
consonant_count = 0
18+
19+
for ch in comb:
20+
if ch in vowels:
21+
vowel_count += 1
22+
else:
23+
consonant_count += 1
24+
25+
if vowel_count >= 1 and consonant_count >= 2:
26+
print(''.join(comb))

0 commit comments

Comments
 (0)