반응형
import sys
from itertools import combinations
def divide_alphabet(alphabet):
vowel = []
consonant = []
for a in alphabet:
if a in ['a', 'e', 'i', 'o', 'u']:
vowel.append(a)
else:
consonant.append(a)
return vowel, consonant
def make_subset_num(L):
LV = 1
LC = 2
num = []
for v in range(LV,L-LC+1):
num.append([v,L-v])
return num
def make_subset(num, vowel, consonant):
subset = []
for n in num:
subset_v = list(combinations(vowel, n[0]))
subset_c = list(combinations(consonant, n[1]))
for sv in subset_v:
for sc in subset_c:
subset.append(sorted(list(sv)+list(sc)))
return sorted(subset)
if __name__ == '__main__':
L, C = map(int, sys.stdin.readline().split())
alphabet = list(sys.stdin.readline().split())
vowel, consonant = divide_alphabet(alphabet)
num = make_subset_num(L)
subset = make_subset(num, vowel, consonant)
for sub in subset:
print(''.join(sub))
반응형