본문 바로가기
알고리즘/백준

백준-1759번(암호 만들기)-python3

by nyeongha 2023. 11. 24.
from itertools import combinations
import sys
input=sys.stdin.readline


L,C=map(int, input().split())
CL=list(map(str,input().split()))

CL.sort()
m=["a", "e", "i", "o", "u"]

a=list(combinations(CL, L))

ss=[]

def bt(a):
    for i in a:
        cnt=0
        i=list(i)
        k=list(i)
        for j in k:
            if j in m:
                i.pop(i.index(j))
                cnt+=1
        if len(i)>=2 and cnt>=1:
            ss.append(k)
        


bt(a)
for i in ss:
    for k in i:
        print(k,end='')
    print(end="\n")