Skip to content

Instantly share code, notes, and snippets.

@inspirit941
Created March 25, 2020 04:12
Show Gist options
  • Save inspirit941/fa802afa877b9d5c2044ecf693ce1077 to your computer and use it in GitHub Desktop.
Save inspirit941/fa802afa877b9d5c2044ecf693ce1077 to your computer and use it in GitHub Desktop.
from itertools import combinations
import sys
L, C = map(int, sys.stdin.readline().split())
arr = sys.stdin.readline().split()
arr.sort()
vowel = {'a','e','i','o','u'}
consonant = set(list("abcdefghijklmnopqrstuvwxyz")) - vowel
candidate = combinations(range(len(arr)), L)
for value in candidate:
temp = []
for i in range(L):
temp.append(arr[value[i]])
if len(set(temp) & vowel) >= 1 and len(set(temp) & consonant) >= 2:
print("".join(temp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment