Seven-letter words with only one vowel
This is my solution.
Code:
echo; echo 'Find seven-letter words which have only one vowel.' Daniel B. Martin . |
I searched my personal library and found this one.
Code:
egrep "^.{7}$" $WordList \ . |
There don't seem to be any modules or built-in character sets which include a comprehensive group of vowels, at least not externally. However, CPAN's Unicode::Normalize can convert to ASCII and then you can check with a pattern similar to one of the ones which you have used above.
Code:
#!/usr/bin/perl I think that's about as short as it can be with the Unicode constraint. If you are sticking with ASCII then sed or grep would be enough. Edit: The old version allowed up to one vowel but did not require one. The modification requires exactly one vowel. |
Code:
awk -F'[aeiou]' '/^\w{7}$/ && NF == 2' $WordList |
you can also try to
1. filter 7 letter words, 2. remove all the non-wovels (like your sed) 3. check length again, should be 1 but the post #3 and #4 are definitely much better. I would avoid using pipe chains if possible. |
"Holy Grail, Batman!"
I think I'll keep my inelegant solution to myself! |
Code:
awk ' Code:
awk ' |
Hint:
Filter for words which do match [aeéiouy] in a suitable words-file, then pipe the results to keep only those which do not match [aeéiouy].*[aeéiouy]. Finally, filter out all which are not seven-letter words. (Rearrange the order of piped operations as you like.) A "shell one-liner," given a suitable "words file," can solve this. No programming is required. Q.E.D. |
All times are GMT -5. The time now is 05:48 AM. |