2021-02-01
문제 : https://www.acmicpc.net/problem/1759
1759번: 암호 만들기
첫째 줄에 두 정수 L, C가 주어진다. (3 ≤ L ≤ C ≤ 15) 다음 줄에는 C개의 문자들이 공백으로 구분되어 주어진다. 주어지는 문자들은 알파벳 소문자이며, 중복되는 것은 없다.
www.acmicpc.net
조합으로 풀 수 있는 문제였고, 범위 수가 크지 않아서 combinations 사용해서 풀 수 있는 간단한 문제였다
[소스코드]
이제 깃헙 링크도 같이 달기로 했음
https://github.com/jisun1125/algorithm-problem-solving/blob/main/baekjoon/no_1759.py
jisun1125/algorithm-problem-solving
Algorithms. Contribute to jisun1125/algorithm-problem-solving development by creating an account on GitHub.
github.com
from itertools import combinations
l, c = map(int, input().split()) # l: 암호 길이, c: 알파벳 개수
pwd = sorted(list(input().split()))
comb = combinations(pwd, l)
sample = 'aeiou'
for c in comb:
cnt = 0
for i in c:
if i in sample:
cnt += 1
if (cnt >= 1) and (cnt <= l-2): # 암호 중에서 모음이 1자 이상, 자음이 2자 이상
print(''.join(c))