Find words which contains all the vowels: Difference between revisions

m
syntax highlighting fixup automation
(J)
m (syntax highlighting fixup automation)
Line 13:
 
=={{header|11l}}==
<langsyntaxhighlight lang="11l">L(word) File(‘unixdict.txt’).read().split("\n")
I word.len > 10
L(vowel) (‘a’, ‘e’, ‘i’, ‘o’, ‘u’)
Line 19:
L.break
L.was_no_break
print(word)</langsyntaxhighlight>
 
{{out}}
Line 52:
=={{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.
<langsyntaxhighlight Actionlang="action!">BYTE FUNC Once(CHAR ARRAY text CHAR c)
BYTE i,n
 
Line 105:
 
FindWords(fname)
RETURN</langsyntaxhighlight>
{{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]
Line 115:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
with Ada.Strings.Maps;
with Ada.Strings.Fixed;
Line 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 195:
OD;
close( input file )
FI</langsyntaxhighlight>
{{out}}
<pre>
Line 226:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">words: read.lines relative "unixdict.txt"
vowels: ["a" "e" "i" "o" "u"]
containsAllVowels?: function [w][
Line 241:
print word
]
]</langsyntaxhighlight>
 
{{out}}
Line 272:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">FileRead, db, % A_Desktop "\unixdict.txt"
vowels := ["a", "e", "i", "o", "u"]
main:
Line 287:
result .= word "`n"
}
MsgBox, 262144, , % result</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 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 329:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 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 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 384:
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let reads(v) = valof
Line 416:
while reads(word) if testword(word) do writef("%S*N", word)
endread()
$)</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 445:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <bitset>
#include <cctype>
#include <cstdlib>
Line 486:
}
return EXIT_SUCCESS;
}</langsyntaxhighlight>
 
{{out}}
Line 518:
 
=={{header|CLU}}==
<langsyntaxhighlight 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)
Line 547:
stream$close(fstream)
end
end start_up</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 576:
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. ALL-VOWELS.
Line 620:
IF LEN IS GREATER THAN 10
AND 1 IS EQUAL TO A AND E AND I AND O AND U,
DISPLAY WORD.</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 650:
=={{header|Common Lisp}}==
 
<langsyntaxhighlight 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)
Line 660:
(write-line word))))
 
(print-words "unixdict.txt" 10 "aeiou" 1)</langsyntaxhighlight>
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.IoUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Find_words_which_contains_all_the_vowels;
 
Line 717:
 
readln;
end.</langsyntaxhighlight>
{{out}}
<pre> 1: ambidextrous
Line 746:
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">\util.g
 
proc all_vowels(*char line) bool:
Line 789:
close(dict)
corp</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 818:
 
=={{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 853:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: grouping io.encodings.ascii io.files math prettyprint
sequences sets.extras ;
 
Line 859:
[ length 10 > ] filter
[ non-repeating "aeiou" superset? ] filter
5 group simple-table.</langsyntaxhighlight>
{{out}}
<pre>
Line 871:
=={{header|Forth}}==
{{works with|Gforth}}
<langsyntaxhighlight lang="forth">: contains-all-vowels-once ( addr u -- ? )
0 { vowels }
0 do
Line 920:
 
main
bye</langsyntaxhighlight>
 
{{out}}
Line 952:
 
=={{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 981:
 
close #1
</syntaxhighlight>
</lang>
{{out}}<pre>
ambidextrous
Line 1,011:
 
=={{header|Frink}}==
<langsyntaxhighlight 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]
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,047:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,094:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,129:
 
=={{header|J}}==
<langsyntaxhighlight Jlang="j"> >(#~ ((]-:&(/:~)([-.-.))&'aeiou' * 10 <#)@>) cutLF fread 'unixdict.txt'
ambidextrous
bimolecular
Line 1,154:
praseodymium
stupefaction
sulfonamide</langsyntaxhighlight>
 
=={{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 1,179:
=={{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 1,192:
 
=={{header|Ksh}}==
<langsyntaxhighlight lang="ksh">
#!/bin/ksh
 
Line 1,225:
_allvowels "$REPLY"
(( $? )) && print "$((++i)). $REPLY"
done < ${dict}</langsyntaxhighlight>
{{out}}<pre>1. ambidextrous
2. bimolecular
Line 1,253:
 
=={{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 1,260:
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 1,311:
ts := Texts.Disconnect(dict);
fs := SeqIO.Close(file);
END Vowels.</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 1,340:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils
 
const Vowels = ['a', 'e', 'i', 'o', 'u']
Line 1,352:
break checkWord
inc count
stdout.write word.align(15), if count mod 5 == 0: '\n' else: ' '</langsyntaxhighlight>
 
{{out}}
Line 1,362:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict;
Line 1,368:
 
@ARGV = 'unixdict.txt';
length > 11 and !/([aeiou]).*\1/ and tr/aeiou// == 5 and print while <>;</langsyntaxhighlight>
{{out}}
ambidextrous
Line 1,397:
 
=={{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 1,403:
<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 1,410:
 
=={{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 1,437:
end;
end;
end allTheVowels;</langsyntaxhighlight>
{{out}}
<pre>ambidextrous
Line 1,467:
=={{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,484:
if frequency['a']==frequency['e']==frequency['i']==frequency['o']==frequency['u']==1:
print(word)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,516:
=={{header|R}}==
Adapting this from https://rosettacode.org/wiki/Find_words_which_contain_the_most_consonants#R is trivial.
<langsyntaxhighlight lang="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,539:
 
=={{header|Red}}==
<langsyntaxhighlight lang="rebol">Red[]
 
vowels: charset "aeiou"
Line 1,562:
print word
]
]</langsyntaxhighlight>
{{out}}
<pre>
Line 1,598:
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,626:
/*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,661:
=== 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,688:
/*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,741:
end
return sum
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,775:
 
=={{header|Ruby}}==
<langsyntaxhighlight 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>
</lang>
{{out}}
<pre>ambidextrous
Line 1,808:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Foundation
 
func containsAllVowelsOnce(_ word: String) -> Bool {
Line 1,847:
} catch {
print(error.localizedDescription)
}</langsyntaxhighlight>
 
{{out}}
Line 1,880:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight lang="ecmascript">import "io" for File
import "/fmt" for Fmt
 
Line 1,894:
count = count + 1
Fmt.print("$2d: $s", count, w)
}</langsyntaxhighlight>
 
{{out}}
Line 1,926:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">string 0; \Use zero-terminated strings
int I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
Line 1,958:
if AllVowels then [Text(0, Word); CrLf(0)];
until Ch = EOF;
]</langsyntaxhighlight>
 
{{out}}
10,327

edits