Find words which contains all the vowels: Difference between revisions

m
(Add Modula-2)
m (→‎{{header|Wren}}: Minor tidy)
 
(33 intermediate revisions by 20 users not shown)
Line 11:
{{Template:Strings}}
<br><br>
 
=={{header|11l}}==
<syntaxhighlight lang="11l">L(word) File(‘unixdict.txt’).read().split("\n")
I word.len > 10
L(vowel) (‘a’, ‘e’, ‘i’, ‘o’, ‘u’)
I word.count(vowel) != 1
L.break
L.was_no_break
print(word)</syntaxhighlight>
 
{{out}}
<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
 
=={{header|Action!}}==
In the following solution the input file [https://gitlab.com/amarok8bit/action-rosetta-code/-/blob/master/source/unixdict.txt unixdict.txt] is loaded from H6 drive. Altirra emulator automatically converts CR/LF character from ASCII into 155 character in ATASCII charset used by Atari 8-bit computer when one from H6-H10 hard drive under DOS 2.5 is used.
<syntaxhighlight lang="action!">BYTE FUNC Once(CHAR ARRAY text CHAR c)
BYTE i,n
 
i=1 n=0
FOR i=1 TO text(0)
DO
IF text(i)=c THEN
n==+1
IF n>1 THEN
RETURN (0)
FI
FI
OD
IF n=1 THEN
RETURN (1)
FI
RETURN (0)
 
BYTE FUNC IsValidWord(CHAR ARRAY word)
IF word(0)<=10 THEN RETURN (0) FI
IF Once(word,'a)=0 THEN RETURN(0) FI
IF Once(word,'e)=0 THEN RETURN(0) FI
IF Once(word,'i)=0 THEN RETURN(0) FI
IF Once(word,'o)=0 THEN RETURN(0) FI
IF Once(word,'u)=0 THEN RETURN(0) FI
RETURN (1)
 
PROC FindWords(CHAR ARRAY fname)
CHAR ARRAY line(256)
CHAR ARRAY tmp(256)
BYTE pos,dev=[1]
 
pos=2
Close(dev)
Open(dev,fname,4)
WHILE Eof(dev)=0
DO
InputSD(dev,line)
IF IsValidWord(line) THEN
IF pos+line(0)>=39 THEN
PutE() pos=2
FI
Print(line) Put(32)
pos==+line(0)+1
FI
OD
Close(dev)
RETURN
 
PROC Main()
CHAR ARRAY fname="H6:UNIXDICT.TXT"
 
FindWords(fname)
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Find_words_which_contains_all_the_vowels.png Screenshot from Atari 8-bit computer]
<pre>
ambidextrous bimolecular cauliflower communicable communicate consanguine consultative countervail exclusionary
grandiloquent importunate incommutable incomputable insupportable loudspeaking malnourished mensuration
oneupmanship pandemonium permutation perturbation portraiture praseodymium stupefaction sulfonamide
</pre>
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
with Ada.Strings.Maps;
with Ada.Strings.Fixed;
Line 44 ⟶ 146:
end loop;
Close (File);
end Find_All_Vowels;</langsyntaxhighlight>
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68"># find 11 or more character words that contain all the vowels once #
 
# read the list of words and look for suitable words #
Line 93 ⟶ 195:
OD;
close( input file )
FI</langsyntaxhighlight>
{{out}}
<pre>
Line 124 ⟶ 226:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">words: read.lines relative "unixdict.txt"
vowels: ["a" "e" "i" "o" "u"]
containsAllVowels?: function [w][
Line 139 ⟶ 241:
print word
]
]</langsyntaxhighlight>
 
{{out}}
Line 170 ⟶ 272:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">FileRead, db, % A_Desktop "\unixdict.txt"
vowels := ["a", "e", "i", "o", "u"]
main:
Line 185 ⟶ 287:
result .= word "`n"
}
MsgBox, 262144, , % result</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 214 ⟶ 316:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f FIND_WORDS_WHICH_CONTAINS_ALL_THE_VOWELS.AWK unixdict.txt
{ if (length($0) <= 10) {
Line 227 ⟶ 329:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 258 ⟶ 360:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 DEFINT A-Z: DEFSTR C,W
20 OPEN "I",1,"UNIXDICT.TXT"
30 IF EOF(1) THEN CLOSE #1: END
Line 273 ⟶ 375:
140 NEXT N
150 IF A=1 AND E=1 AND I=1 AND O=1 AND U=1 THEN PRINT W,
160 GOTO 30</langsyntaxhighlight>
{{out}}
<pre>ambidextrous bimolecular cauliflower communicable communicate
Line 282 ⟶ 384:
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let reads(v) = valof
Line 314 ⟶ 416:
while reads(word) if testword(word) do writef("%S*N", word)
endread()
$)</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 341 ⟶ 443:
stupefaction
sulfonamide</pre>
 
=={{header|C}}==
<syntaxhighlight lang="c">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
 
/* "Use the dictionary unixdict.txt" */
#define DICTIONARY_FILE_NAME "unixdict.txt"
 
/* "The length of any word shown should be >10" */
#define MIN_WORD_LENGTH 11
 
 
char *create_word_buffer( const char *file_name, size_t *buffer_size );
int verify_vowels( const char *word, size_t word_length );
int wait_for_return( void );
 
 
int main() {
size_t buffer_size = 0;
char *buffer = create_word_buffer( DICTIONARY_FILE_NAME, &buffer_size );
 
if( buffer ) {
FILE *f = fopen( DICTIONARY_FILE_NAME, "r" );
 
if( f ) {
while( fgets(buffer,buffer_size,f) ) {
size_t l = strlen( buffer );
if( '\n'==buffer[l-1] ) buffer[--l] = '\0';
 
if( l>=MIN_WORD_LENGTH && verify_vowels(buffer,l) ) {
printf( "%s\n", buffer );
}
}
 
fclose( f ); f = NULL; /* cleanup */
} else puts( "Couldn't open dictionary file." );
 
free( buffer ); buffer = NULL; /* cleanup */
} else puts( "Couldn't create word buffer." );
 
return wait_for_return();
}
 
 
/*==============================================================================
No need to verify any parameters in any of the following function - the caller
did his homeworks.
==============================================================================*/
 
 
size_t get_line_length( FILE *f ) {
size_t line_length = 0;
int c, ok;
 
do {
c = fgetc(f);
ok = '\n'!=c&&EOF!=c;
line_length += ok;
} while( ok );
 
return line_length;
}
 
 
size_t find_longest_line_in_file( const char *file_name ) {
size_t max_line_length = ((size_t)-1);
 
FILE *f = fopen( file_name, "r" );
 
if( f ) {
max_line_length = 0;
 
while( !feof(f) ) {
size_t line_length = get_line_length( f );
 
if( line_length>max_line_length )
max_line_length = line_length;
}
 
fclose( f ); f = NULL;
}
 
return max_line_length;
}
 
 
char *create_word_buffer( const char *file_name, size_t *buffer_size ) {
char *buffer = NULL;
 
size_t max_line_length = find_longest_line_in_file( file_name );
 
if( ((size_t)-1)!=max_line_length ) {
buffer = calloc( max_line_length+2, sizeof(*buffer) );
if( buffer ) *buffer_size = max_line_length+2;
}
 
return buffer;
}
 
 
int verify_vowels( const char *word, size_t word_length ) {
int vowel_instances[5] = {0};
size_t i;
 
for( i=0; i<word_length; ++i ) {
switch( word[i] ) {
case 'A': case 'a': vowel_instances[0]++; break;
case 'E': case 'e': vowel_instances[1]++; break;
case 'I': case 'i': vowel_instances[2]++; break;
case 'O': case 'o': vowel_instances[3]++; break;
case 'U': case 'u': vowel_instances[4]++; break;
default: ;
}
}
 
return 1==vowel_instances[0] &&
1==vowel_instances[1] &&
1==vowel_instances[2] &&
1==vowel_instances[3] &&
1==vowel_instances[4];
}
 
 
int wait_for_return( void ) {
puts( "\nPress Return to exit... " );
while( '\n'!=getchar() );
return 0;
}
</syntaxhighlight>
 
{{out}}
<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
 
Press Return to exit...
</pre>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <bitset>
#include <cctype>
#include <cstdlib>
Line 384 ⟶ 649:
}
return EXIT_SUCCESS;
}</langsyntaxhighlight>
 
{{out}}
Line 414 ⟶ 679:
25: sulfonamide
</pre>
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">has_all_vowels_once = proc (s: string) returns (bool)
vowels: string := "aeiou"
vowel_counts: array[int] := array[int]$fill(1,string$size(vowels),0)
for c: char in string$chars(s) do
v: int := string$indexc(c, vowels)
if v>0 then
vowel_counts[v] := vowel_counts[v] + 1
if vowel_counts[v] > 1 then return(false) end
end
end
for i: int in array[int]$elements(vowel_counts) do
if i ~= 1 then return(false) end
end
return(true)
end has_all_vowels_once
 
start_up = proc ()
po: stream := stream$primary_output()
fname: file_name := file_name$parse("unixdict.txt")
fstream: stream := stream$open(fname, "read")
while true do
word: string := stream$getl(fstream)
if string$size(word) > 10 cand has_all_vowels_once(word) then
stream$putl(po, word)
end
end except when end_of_file:
stream$close(fstream)
end
end start_up</syntaxhighlight>
{{out}}
<pre>ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide</pre>
 
=={{header|COBOL}}==
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. ALL-VOWELS.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DICT ASSIGN TO DISK
ORGANIZATION LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD DICT
LABEL RECORD STANDARD
VALUE OF FILE-ID IS "unixdict.txt".
01 WORD PIC X(64).
WORKING-STORAGE SECTION.
01 A PIC 99.
01 E PIC 99.
01 I PIC 99.
01 O PIC 99.
01 U PIC 99.
01 LEN PIC 99.
PROCEDURE DIVISION.
BEGIN.
OPEN INPUT DICT.
READ-WORD.
READ DICT, AT END CLOSE DICT, STOP RUN.
PERFORM CHECK-WORD.
GO TO READ-WORD.
CHECK-WORD.
MOVE ZERO TO LEN, A, E, I, O, U.
INSPECT WORD TALLYING LEN FOR CHARACTERS
BEFORE INITIAL SPACE.
INSPECT WORD TALLYING A FOR ALL 'a'.
INSPECT WORD TALLYING E FOR ALL 'e'.
INSPECT WORD TALLYING I FOR ALL 'i'.
INSPECT WORD TALLYING O FOR ALL 'o'.
INSPECT WORD TALLYING U FOR ALL 'u'.
IF LEN IS GREATER THAN 10
AND 1 IS EQUAL TO A AND E AND I AND O AND U,
DISPLAY WORD.</syntaxhighlight>
{{out}}
<pre>ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide</pre>
 
=={{header|Common Lisp}}==
 
<syntaxhighlight lang="lisp">(defun print-words (file-name word-length vowels vowels-number)
(with-open-file (dictionary file-name :if-does-not-exist nil)
(loop for word = (read-line dictionary nil nil)
while word
when (and (> (length word) word-length)
(every #'(lambda (c)
(= (count c word :test #'char-equal) vowels-number))
vowels)) do
(write-line word))))
 
(print-words "unixdict.txt" 10 "aeiou" 1)</syntaxhighlight>
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.IoUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Find_words_which_contains_all_the_vowels;
 
Line 470 ⟶ 880:
 
readln;
end.</langsyntaxhighlight>
{{out}}
<pre> 1: ambidextrous
Line 497 ⟶ 907:
24: stupefaction
25: sulfonamide</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">\util.g
 
proc all_vowels(*char line) bool:
word a, e, i, o, u;
char ch;
a := 0;
e := 0;
i := 0;
o := 0;
u := 0;
while
ch := line*;
line := line + 1;
ch ~= '\e' and a<=1 and e<=1 and i<=1 and o<=1 and u<=1
do
if ch='a' then a := a + 1
elif ch='e' then e := e + 1
elif ch='i' then i := i + 1
elif ch='o' then o := o + 1
elif ch='u' then u := u + 1
fi
od;
a=1 and e=1 and i=1 and o=1 and u=1
corp
 
proc nonrec main() void:
file(1024) dictfile;
[32] char buf;
*char line;
channel input text dict;
open(dict, dictfile, "unixdict.txt");
line := &buf[0];
while readln(dict; line) do
if CharsLen(line) > 10 and all_vowels(line) then
writeln(line)
fi
od;
close(dict)
corp</syntaxhighlight>
{{out}}
<pre>ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide</pre>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Words which containing all the vowels once . Nigel Galloway: February 17th., 2021
let fN g=if String.length g < 11 then false else let n=Map.ofSeq (Seq.countBy id g) in let fN g=n.ContainsKey g && n.[g]=1 in fN 'a' && fN 'i' && fN 'o' && fN 'u' && fN 'e'
seq{use n=System.IO.File.OpenText("unixdict.txt") in while not n.EndOfStream do yield n.ReadLine()}|>Seq.filter fN|>Seq.iter(printfn "%s")
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 532 ⟶ 1,014:
sulfonamide
</pre>
 
 
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: grouping io.encodings.ascii io.files math prettyprint
sequences sets.extras ;
 
Line 542 ⟶ 1,022:
[ length 10 > ] filter
[ non-repeating "aeiou" superset? ] filter
5 group simple-table.</langsyntaxhighlight>
{{out}}
<pre>
Line 554 ⟶ 1,034:
=={{header|Forth}}==
{{works with|Gforth}}
<langsyntaxhighlight lang="forth">: contains-all-vowels-once ( addr u -- ? )
0 { vowels }
0 do
Line 603 ⟶ 1,083:
 
main
bye</langsyntaxhighlight>
 
{{out}}
Line 635 ⟶ 1,115:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">dim as boolean v(1 to 5)
dim as string s, c, q(1 to 5) = {"a","e","i","o","u"}
dim as integer i, j, n
Line 664 ⟶ 1,144:
 
close #1
</syntaxhighlight>
</lang>
{{out}}<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
 
=={{header|Frink}}==
<syntaxhighlight lang="frink">for word = select[lines["https://web.archive.org/web/20180611003215if_/http://www.puzzlers.org:80/pub/wordlists/unixdict.txt"], {|x| length[x] > 10}]
{
d = countToDict[charList[word]]
if d@"a" == 1 and d@"e" == 1 and d@"i" == 1 and d@"o" == 1 and d@"u" == 1
println[word]
}</syntaxhighlight>
{{out}}
<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES}
 
local fn Words as CFArrayRef
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" )
CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
CFArrayRef array = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
PredicateRef predicate = fn PredicateWithFormat( @"self.length > %d", 10 )
end fn = fn ArrayFilteredArrayUsingPredicate( array, predicate )
 
void local fn DoIt
CFArrayRef words = fn Words
CFStringRef wd
for wd in words
long index, a = 0, e = 0, i = 0, o = 0, u = 0
for index = 0 to len(wd) - 1
select ( fn StringCharacterAtIndex( wd, index ) )
case _"a" : a++
case _"e" : e++
case _"i" : i++
case _"o" : o++
case _"u" : u++
end select
next
if ( a == 1 and e == 1 and i == 1 and o == 1 and u == 1 )
print wd
end if
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
 
{{out}}
<pre>
ambidextrous
bimolecular
Line 694 ⟶ 1,277:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 741 ⟶ 1,324:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 774 ⟶ 1,357:
</pre>
 
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">
condition :: String -> Bool
condition s = all (\vow -> count vow s == 1 ) "aeiou"
where
count :: Char -> String -> Int
count letter word = length $ filter ( == letter ) word
 
main :: IO ( )
main = do
theLines <- readFile "unixdict.txt"
let selected = filter condition $ words theLines
mapM_ putStrLn selected</syntaxhighlight>
 
{{out}}
(with my version of unixdict.txt)
<pre>
ambidextrous
aureomycin
bimolecular
cauliflower
colatitude
communicable
communicate
consanguine
consultative
countervail
dalhousie
denudation
deputation
dialogue
equivocal
euphorbia
euphoria
exclusionary
exhaustion
exhumation
exudation
exultation
facetious
fluoridate
gelatinous
grandiloquent
gregarious
houdaille
importunate
incommutable
incomputable
inoculate
insupportable
loudspeaking
malnourished
mendacious
mensuration
oneupmanship
pandemonium
permutation
persuasion
perturbation
pneumonia
portraiture
praseodymium
precarious
precaution
quasiorder
refutation
reputation
sequoia
stupefaction
sulfonamide
tambourine
tenacious
veracious
vexatious
</pre>
 
or, adding the restriction to words of more than 10 characters, and using Data.Set to identify words with a set of 5 unique vowel characters, which have no more than 5 vowel characters in total:
 
<syntaxhighlight lang="haskell">import Data.Set (Set, fromList, member, size)
 
---- WORDS OVER 10 CHARS WHICH CONTAIN EACH VOWEL ONCE ---
 
p :: String -> Bool
p = ((&&) . (10 <) . length) <*> eachVowelOnce
 
eachVowelOnce :: String -> Bool
eachVowelOnce w =
all (5 ==) $
[length, size . fromList] <*> [filter (`member` vowels) w]
 
vowels :: Set Char
vowels = fromList "aeiou"
 
--------------------------- TEST -------------------------
main :: IO ()
main =
readFile "unixdict.txt"
>>= (mapM_ putStrLn . filter p . lines)</syntaxhighlight>
{{Out}}
<pre>ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide</pre>
 
=={{header|J}}==
<syntaxhighlight lang="j"> >(#~ ((]-:&(/:~)([-.-.))&'aeiou' * 10 <#)@>) cutLF fread 'unixdict.txt'
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="jq">
<lang jq>
select(length > 10)
| . as $w
| select( all("a","e","i","o","u";
. as $v | ($w | test($v) and (test( "\($v).*\($v)")|not))))
</syntaxhighlight>
</lang>
{{out}}
Invocation example: jq -Rr -f program.jq unixdict.txt
Line 798 ⟶ 1,533:
=={{header|Julia}}==
See [[Alternade_words]] for the foreachword function.
<langsyntaxhighlight lang="julia">hassallthevowels(w, d) = all(c -> count(x -> x == c, w) == 1, collect("aeiou")) ? w : ""
foreachword("unixdict.txt", hassallthevowels, colwidth=18, minlen=11, numcols=5)
</langsyntaxhighlight>{{out}}<pre>
Word source: unixdict.txt
 
Line 809 ⟶ 1,544:
perturbation portraiture praseodymium stupefaction sulfonamide
</pre>
 
=={{header|Ksh}}==
<syntaxhighlight lang="ksh">
#!/bin/ksh
 
# Find words which contains all the vowels
 
# # Variables:
#
dict='../unixdict.txt'
integer MINLENGTH=10
typeset -a vowels=( a e i o u )
 
# # Functions:
#
# # Function _allvowels(str) - return 1 if str contains all 5 vowels
#
function _allvowels {
typeset _str ; typeset -l _str="$1"
typeset _i ; integer _i
 
for ((_i=0; _i<${#vowels[*]}; _i++)); do
[[ ${_str} != *+(${vowels[_i]})* ]] && return 0
[[ ${_str/${vowels[_i]}/} == *+(${vowels[_i]})* ]] && return 0
done
return 1
}
######
# main #
######
integer i=0
while read; do
(( ${#REPLY} <= MINLENGTH )) && continue
_allvowels "$REPLY"
(( $? )) && print "$((++i)). $REPLY"
done < ${dict}</syntaxhighlight>
{{out}}<pre>1. ambidextrous
2. bimolecular
3. cauliflower
4. communicable
5. communicate
6. consanguine
7. consultative
8. countervail
9. exclusionary
10. grandiloquent
11. importunate
12. incommutable
13. incomputable
14. insupportable
15. loudspeaking
16. malnourished
17. mensuration
18. oneupmanship
19. pandemonium
20. permutation
21. perturbation
22. portraiture
23. praseodymium
24. stupefaction
25. sulfonamide</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">vowels=Characters["euioa"];
dict=Once[Import["https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt"]];
dict//=StringSplit[#,"\n"]&;
Line 818 ⟶ 1,614:
dict//=Select[Last/*DuplicateFreeQ];
dict//=Select[Last/*Length/*EqualTo[Length[vowels]]];
dict[[All,1]]</langsyntaxhighlight>
{{out}}
<pre>{ambidextrous, bimolecular, cauliflower, communicable, communicate, consanguine, consultative, countervail, exclusionary, grandiloquent, importunate, incommutable, incomputable, insupportable, loudspeaking, malnourished, mensuration, oneupmanship, pandemonium, permutation, perturbation, portraiture, praseodymium, stupefaction, sulfonamide}</pre>
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE Vowels;
IMPORT SeqIO;
IMPORT Texts;
Line 869 ⟶ 1,665:
ts := Texts.Disconnect(dict);
fs := SeqIO.Close(file);
END Vowels.</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 898 ⟶ 1,694:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils
 
const Vowels = ['a', 'e', 'i', 'o', 'u']
Line 910 ⟶ 1,706:
break checkWord
inc count
stdout.write word.align(15), if count mod 5 == 0: '\n' else: ' '</langsyntaxhighlight>
 
{{out}}
Line 920 ⟶ 1,716:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict;
Line 926 ⟶ 1,722:
 
@ARGV = 'unixdict.txt';
length > 11 and !/([aeiou]).*\1/ and tr/aeiou// == 5 and print while <>;</langsyntaxhighlight>
{{out}}
ambidextrous
Line 955 ⟶ 1,751:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">onev</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">word</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">vowel</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">find_all</span><span style="color: #0000FF;">(</span><span style="color: #000000;">vowel</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">))=</span><span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
Line 961 ⟶ 1,757:
<span style="color: #004080;">sequence</span> <span style="color: #000000;">fivev</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">unix_dict</span><span style="color: #0000FF;">(),</span><span style="color: #000000;">allv</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d words: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">fivev</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">fivev</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">))})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 968 ⟶ 1,764:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">allTheVowels: procedure options(main);
countChar: procedure(str, ch) returns(fixed);
declare str char(32) varying, ch char, (i, n) fixed;
Line 995 ⟶ 1,791:
end;
end;
end allTheVowels;</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 1,025 ⟶ 1,821:
=={{header|Python}}==
Tested on Python 3+, the file download will work only if the link is still active. It is possible that you may be able to fetch the file in your browser but download via code may still fail. Check whether you are connected to a VPN, it works on open networks.
<syntaxhighlight lang="python">
<lang Python>
import urllib.request
from collections import Counter
Line 1,042 ⟶ 1,838:
if frequency['a']==frequency['e']==frequency['i']==frequency['o']==frequency['u']==1:
print(word)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,071 ⟶ 1,867:
sulfonamide
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ [] swap ]'[ swap
witheach
[ dup nested
unrot over do
iff [ dip join ]
else nip ]
drop ] is filter ( [ --> [ )
 
[ 2dup peek
1+ unrot poke ] is pink ( [ n --> [ )
 
[ ' [ 0 0 0 0 0 0 ]
swap witheach
[ lower
$ "aeiou" find
pink ]
-1 split drop
' [ 1 1 1 1 1 ] = ] is valid ( [ --> b )
 
$ "rosetta/unixdict.txt" sharefile drop nest$
filter [ size 10 > ]
filter valid
70 wrap$</syntaxhighlight>
 
{{out}}
 
<pre>ambidextrous bimolecular cauliflower communicable communicate
consanguine consultative countervail exclusionary grandiloquent
importunate incommutable incomputable insupportable loudspeaking
malnourished mensuration oneupmanship pandemonium permutation
perturbation portraiture praseodymium stupefaction sulfonamide</pre>
 
=={{header|R}}==
Adapting this from https://rosettacode.org/wiki/Find_words_which_contain_the_most_consonants#R is trivial.
<langsyntaxhighlight Rlang="rsplus">dict <- scan("https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt", what = character())
dictBig <- dict[nchar(dict) > 10]
#The following line is equivalent to sapply(c("a", "e", "i", "o", "u"), function(x) stringr::str_count(dictBig, x))
#As with all things with strings in R, life is easier with stringr or stringi.
vowelCount <- sapply(c("a", "e", "i", "o", "u"), function(x) lengths(regmatches(dictBig, gregexec(x, dictBig))))
dictBig[apply(vowelCount, MARGIN = 1, function(x) all(x == 1))]</langsyntaxhighlight>
 
=={{header|Raku}}==
Yet another "Filter a word list" task.
 
<syntaxhighlight lang="raku" perl6line>put +.words, " words found:\n", $_ with 'unixdict.txt'.IO.words\
.grep({ .chars > 10 and all(.comb.Bag<a e i o u>) == 1 })\
.batch(5)».fmt('%-13s').join: "\n";</langsyntaxhighlight>
 
{{out}}
Line 1,095 ⟶ 1,925:
malnourished mensuration oneupmanship pandemonium permutation
perturbation portraiture praseodymium stupefaction sulfonamide </pre>
 
=={{header|Red}}==
<syntaxhighlight lang="rebol">Red[]
 
vowels: charset "aeiou"
 
count-vowels: function [
"Returns the number of vowels in a string"
word [string!]
][
result: 0
foreach letter word [
if find vowels letter [result: result + 1]
]
result
]
 
foreach word read/lines %unixdict.txt [
if all [
10 < length? word
5 = length? intersect word "aeiou"
5 = count-vowels word
][
print word
]
]</syntaxhighlight>
{{out}}
<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
 
=={{header|REXX}}==
Line 1,102 ⟶ 1,986:
They also allows the minimum length to be specified on the command line (CL) as well as the dictionary file identifier.
=== version 1 ===
<langsyntaxhighlight lang="rexx">/*REXX pgm finds all words that contain only one vowel each (no duplication of vowels). */
parse arg minL iFID . /*obtain optional arguments from the CL*/
if minL=='' | minL=="," then minL= 11 /*Not specified? Then use the default.*/
Line 1,130 ⟶ 2,014:
/*stick a fork in it, we're all done. */
say copies('─',30) finds ' words found with only one each of every vowel,' ,
" and with a minimum length of " minL</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the internal default input:}}
<pre>
Line 1,165 ⟶ 2,049:
=== version 2 ===
This REXX version uses the &nbsp; '''countstr''' &nbsp; BIF which returns the count of (a particular) character in a string.
<langsyntaxhighlight lang="rexx">/*REXX pgm finds all words that contain only one vowel each (no duplication of vowels). */
parse arg minL iFID . /*obtain optional arguments from the CL*/
if minL=='' | minL=="," then minL= 11 /*Not specified? Then use the default.*/
Line 1,192 ⟶ 2,076:
/*stick a fork in it, we're all done. */
say copies('─',30) finds ' words found with only one each of every vowel,' ,
" and with a minimum length of " minL</langsyntaxhighlight>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
 
Line 1,245 ⟶ 2,129:
end
return sum
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,277 ⟶ 2,161:
 
</pre>
 
=={{header|RPL}}==
The only way to use <code>unixdict.txt</code> as input is to convert it into a list of 25104 strings. Fortunately, emulators can handle such a big data structure in RAM.
{{works with|Halcyon Calc|4.2.7}}
≪ { }
1 UnixDict SIZE '''FOR''' j
'UnixDict' j GET
'''IF''' DUP SIZE 10 < '''THEN''' DROP '''ELSE'''
{ 5 } 0 CON
1 3 PICK SIZE '''FOR''' j
OVER j DUP SUB
'''IF''' "AEIOUaeiou" SWAP POS '''THEN'''
LAST 1 - 5 MOD 1 +
DUP2 GET 1 + PUT
'''END'''
'''NEXT'''
'''IF''' [ 1 1 1 1 1 ] == '''THEN''' + '''ELSE''' DROP '''END'''
'''END NEXT'''
» '<span style="color:blue">AEIOU</span>' STO
 
{{out}}
<pre>
1: { "ambidextrous" "aureomycin" "bimolecular" "cauliflower" "colatitude" "communicable" "communicate" "consanguine" "consultative" "countervail" "denudation" "deputation" "exclusionary" "exhaustion" "exhumation" "exultation" "fluoridate" "gelatinous" "grandiloquent" "gregarious" "importunate" "incommutable" "incomputable" "insupportable" "loudspeaking" "malnourished" "mendacious" "mensuration" "oneupmanship" "pandemonium" "permutation" "persuasion" "perturbation" "portraiture" "praseodymium" "precarious" "precaution" "quasiorder" "refutation" "reputation" "stupefaction" "sulfonamide" "tambourine" }
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">File.open("unixdict.txt").each(chomp: true) do |word|
puts word if word.size > 10 && word.chars.tally.values_at('a','e','i','o','u').all?(1)
end
</syntaxhighlight>
{{out}}
<pre>ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
 
=={{header|sed}}==
<syntaxhighlight lang="sed">#!/bin/sed -f
 
/^.\{11\}/!d
/^[^a]*a[^a]*$/!d
/^[^e]*e[^e]*$/!d
/^[^i]*i[^i]*$/!d
/^[^o]*o[^o]*$/!d
/^[^u]*u[^u]*$/!d</syntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Foundation
 
func containsAllVowelsOnce(_ word: String) -> Bool {
Line 1,318 ⟶ 2,269:
} catch {
print(error.localizedDescription)
}</langsyntaxhighlight>
 
{{out}}
Line 1,351 ⟶ 2,302:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "io" for File
import "./fmt" for Fmt
 
var wordList = "unixdict.txt" // local copy
Line 1,365 ⟶ 2,316:
count = count + 1
Fmt.print("$2d: $s", count, w)
}</langsyntaxhighlight>
 
{{out}}
Line 1,394 ⟶ 2,345:
24: stupefaction
25: sulfonamide
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">string 0; \Use zero-terminated strings
int I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
def LF=$0A, CR=$0D, EOF=$1A;
 
func AllVowels; \Return 'true' if Word contains all vowels once
int Cnt, I;
[Cnt:= 0;
for I:= 0 to Len-1 do
case Word(I) of
^a: Cnt:= Cnt + $00001;
^e: Cnt:= Cnt + $00010;
^i: Cnt:= Cnt + $00100;
^o: Cnt:= Cnt + $01000;
^u: Cnt:= Cnt + $10000
other [];
return Cnt = $11111;
];
 
[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3
OpenI(3);
repeat I:= 0;
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR
if Ch=LF or Ch=EOF then quit;
Word(I):= Ch;
I:= I+1;
];
Word(I):= 0; \terminate string
Len:= I;
if Len > 10 then
if AllVowels then [Text(0, Word); CrLf(0)];
until Ch = EOF;
]</syntaxhighlight>
 
{{out}}
<pre>
ambidextrous
bimolecular
cauliflower
communicable
communicate
consanguine
consultative
countervail
exclusionary
grandiloquent
importunate
incommutable
incomputable
insupportable
loudspeaking
malnourished
mensuration
oneupmanship
pandemonium
permutation
perturbation
portraiture
praseodymium
stupefaction
sulfonamide
</pre>
9,477

edits