Jump to content

Find words with alternating vowels and consonants: Difference between revisions

m (added related tasks.)
Line 348:
dict, shown = Dict(w => 1 for w in words), 0
for word in words
if (output = condition(word, dict)) != "" && (minlen < 1 || length(word) >= minlen)
shown += 1
print(rpad(wordoutput, colwidth), shown % numcols == 0 ? "\n" : "")
toshow > 0 && toshow <= shown && break
end
end
Line 359:
onlyodds(f, s) = all(c -> f(c), s[1:2:length(s)]) && !any(c -> f(c), s[2:2:length(s)])
onlyevens(f, s) = !any(c -> f(c), s[1:2:length(s)]) && all(c -> f(c), s[2:2:length(s)])
eitheronlyvowels(w, _) = onlyodds(isvowel, w) || onlyevens(isvowel, w) ? w : ""
 
foreachword("unixdict.txt", eitheronlyvowels, minlen = 10)
</lang>{{out}}
<pre>
Word source: unixdict.txt
 
aboriginal apologetic bimolecular borosilicate calorimeter capacitate
capacitive capitoline capitulate caricature colatitude coloratura
4,111

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.