[알고리즘] 조합

김제현·2024년 6월 28일
0

알고리즘

목록 보기
11/17
import sys

input = sys.stdin.readline


L,C = map(int,input().split())
datas = list(input().split())
datas.sort()

choose = []
 
vows = ['a', 'e', 'i', 'o', 'u']
def is_possible(choose):
    vow = 0
    for c in choose:
        if c in vows:
            vow += 1

    con = L - vow
    return (vow >= 1 and con >= 2)
        


def combinations(index, level):
    if level == L:
        if is_possible(choose):
            print(''.join(choose))
        return
    
    for i in range(index, C):
        choose.append(datas[i])
        combinations(i+1, level+1)
        choose.pop()

combinations(0,0)

0개의 댓글