Find words which contains all the vowels: Difference between revisions
Find words which contains all the vowels (view source)
Revision as of 13:04, 27 August 2022
, 1 year agosyntax highlighting fixup automation
(J) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 13:
=={{header|11l}}==
<
I word.len > 10
L(vowel) (‘a’, ‘e’, ‘i’, ‘o’, ‘u’)
Line 19:
L.break
L.was_no_break
print(word)</
{{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.
<
BYTE i,n
Line 105:
FindWords(fname)
RETURN</
{{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}}==
<
with Ada.Strings.Maps;
with Ada.Strings.Fixed;
Line 146:
end loop;
Close (File);
end Find_All_Vowels;</
=={{header|ALGOL 68}}==
<
# read the list of words and look for suitable words #
Line 195:
OD;
close( input file )
FI</
{{out}}
<pre>
Line 226:
=={{header|Arturo}}==
<
vowels: ["a" "e" "i" "o" "u"]
containsAllVowels?: function [w][
Line 241:
print word
]
]</
{{out}}
Line 272:
=={{header|AutoHotkey}}==
<
vowels := ["a", "e", "i", "o", "u"]
main:
Line 287:
result .= word "`n"
}
MsgBox, 262144, , % result</
{{out}}
<pre>ambidextrous
Line 316:
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f FIND_WORDS_WHICH_CONTAINS_ALL_THE_VOWELS.AWK unixdict.txt
{ if (length($0) <= 10) {
Line 329:
exit(0)
}
</syntaxhighlight>
{{out}}
<pre>
Line 360:
=={{header|BASIC}}==
<
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</
{{out}}
<pre>ambidextrous bimolecular cauliflower communicable communicate
Line 384:
=={{header|BCPL}}==
<
let reads(v) = valof
Line 416:
while reads(word) if testword(word) do writef("%S*N", word)
endread()
$)</
{{out}}
<pre>ambidextrous
Line 445:
=={{header|C++}}==
<
#include <cctype>
#include <cstdlib>
Line 486:
}
return EXIT_SUCCESS;
}</
{{out}}
Line 518:
=={{header|CLU}}==
<
vowels: string := "aeiou"
vowel_counts: array[int] := array[int]$fill(1,string$size(vowels),0)
Line 547:
stream$close(fstream)
end
end start_up</
{{out}}
<pre>ambidextrous
Line 576:
=={{header|COBOL}}==
<
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.</
{{out}}
<pre>ambidextrous
Line 650:
=={{header|Common Lisp}}==
<
(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)</
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.IoUtils}}
<syntaxhighlight lang="delphi">
program Find_words_which_contains_all_the_vowels;
Line 717:
readln;
end.</
{{out}}
<pre> 1: ambidextrous
Line 746:
=={{header|Draco}}==
<
proc all_vowels(*char line) bool:
Line 789:
close(dict)
corp</
{{out}}
<pre>ambidextrous
Line 818:
=={{header|F_Sharp|F#}}==
<
// 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>
{{out}}
<pre>
Line 853:
=={{header|Factor}}==
<
sequences sets.extras ;
Line 859:
[ length 10 > ] filter
[ non-repeating "aeiou" superset? ] filter
5 group simple-table.</
{{out}}
<pre>
Line 871:
=={{header|Forth}}==
{{works with|Gforth}}
<
0 { vowels }
0 do
Line 920:
main
bye</
{{out}}
Line 952:
=={{header|FreeBASIC}}==
<
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>
{{out}}<pre>
ambidextrous
Line 1,011:
=={{header|Frink}}==
<
{
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]
}</
{{out}}
<pre>
Line 1,047:
=={{header|Go}}==
<
import (
Line 1,094:
}
}
}</
{{out}}
Line 1,129:
=={{header|J}}==
<
ambidextrous
bimolecular
Line 1,154:
praseodymium
stupefaction
sulfonamide</
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight 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>
{{out}}
Invocation example: jq -Rr -f program.jq unixdict.txt
Line 1,179:
=={{header|Julia}}==
See [[Alternade_words]] for the foreachword function.
<
foreachword("unixdict.txt", hassallthevowels, colwidth=18, minlen=11, numcols=5)
</
Word source: unixdict.txt
Line 1,192:
=={{header|Ksh}}==
<
#!/bin/ksh
Line 1,225:
_allvowels "$REPLY"
(( $? )) && print "$((++i)). $REPLY"
done < ${dict}</
{{out}}<pre>1. ambidextrous
2. bimolecular
Line 1,253:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
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]]</
{{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}}==
<
IMPORT SeqIO;
IMPORT Texts;
Line 1,311:
ts := Texts.Disconnect(dict);
fs := SeqIO.Close(file);
END Vowels.</
{{out}}
<pre>ambidextrous
Line 1,340:
=={{header|Nim}}==
<
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: ' '</
{{out}}
Line 1,362:
=={{header|Perl}}==
<
use strict;
Line 1,368:
@ARGV = 'unixdict.txt';
length > 11 and !/([aeiou]).*\1/ and tr/aeiou// == 5 and print while <>;</
{{out}}
ambidextrous
Line 1,397:
=={{header|Phix}}==
<!--<
<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>
<!--</
{{out}}
<pre>
Line 1,410:
=={{header|PL/I}}==
<
countChar: procedure(str, ch) returns(fixed);
declare str char(32) varying, ch char, (i, n) fixed;
Line 1,437:
end;
end;
end allTheVowels;</
{{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">
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>
{{out}}
<pre>
Line 1,516:
=={{header|R}}==
Adapting this from https://rosettacode.org/wiki/Find_words_which_contain_the_most_consonants#R is trivial.
<
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))]</
=={{header|Raku}}==
Yet another "Filter a word list" task.
<syntaxhighlight lang="raku"
.grep({ .chars > 10 and all(.comb.Bag<a e i o u>) == 1 })\
.batch(5)».fmt('%-13s').join: "\n";</
{{out}}
Line 1,539:
=={{header|Red}}==
<
vowels: charset "aeiou"
Line 1,562:
print word
]
]</
{{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 ===
<
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</
{{out|output|text= when using the internal default input:}}
<pre>
Line 1,661:
=== version 2 ===
This REXX version uses the '''countstr''' BIF which returns the count of (a particular) character in a string.
<
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</
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br>
=={{header|Ring}}==
<
load "stdlib.ring"
Line 1,741:
end
return sum
</syntaxhighlight>
{{out}}
<pre>
Line 1,775:
=={{header|Ruby}}==
<
puts word if word.size > 10 && word.chars.tally.values_at('a','e','i','o','u').all?(1)
end
</syntaxhighlight>
{{out}}
<pre>ambidextrous
Line 1,808:
=={{header|Swift}}==
<
func containsAllVowelsOnce(_ word: String) -> Bool {
Line 1,847:
} catch {
print(error.localizedDescription)
}</
{{out}}
Line 1,880:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 1,894:
count = count + 1
Fmt.print("$2d: $s", count, w)
}</
{{out}}
Line 1,926:
=={{header|XPL0}}==
<
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;
]</
{{out}}
|