Determine the longest possible word that contains exactly 4 of the vowels in alphabetical order.
*** Archaic/esoteric words are valid. However, slangs, acronyms/abbreviations, hyphenated words like X-ray, A-bomb are NOT permissible.
**** The half-vowel y is not considered as a vowel.
Note: The 4 different vowels are limited to one instance of a given vowel.
Clearly the result will depend on the completeness of one's list of words. The word list I have contains 46893 words in a list variable called "words". There may be more solutions of the same word length, or longer words found in a more complete list.
I found:
brachypterous and
transgression, each with 13 letters.
The word "brachypterous" means having rudimentary or abnormally small wings.
At first, I had a more complex algorithm until I realized I only had to reduce each word to its vowels and then check for one of five patterns.
----------
"words" is a list containing 46893 words
vowels = 'aeiou' #['a','e','i','o','u']
vowels4 = ['eiou','aiou','aeou','aeiu','aeio']
w1 = []
w2 = []
for w in words:
vwlsOnly = ''.join(c for c in w if c in vowels)
if vwlsOnly in vowels4:
w1.append(w)
maxL = 0
for w in w1:
maxL = max(maxL,len(w))
for w in w1:
if len(w) == maxL:
w2.append(w)
print(w2)
OUTPUT: ['brachypterous', 'transgression']
|
Posted by Larry
on 2022-12-15 08:38:08 |