Find words which contain the most consonants: Difference between revisions

Added R.
(Added R.)
Line 1,388:
347 most consonant words: {{9,"comprehensible"},{8,"administrable"},"...",{4,"bourgeoisie"},{4,"onomatopoeia"}}
</pre>
 
=={{header|R}}==
Far and away the hardest part of this task is filtering down the dict until it only contains words with no repeated consonants. If we only had to find the word with the most consonants, this would be easy.
<lang R>dict <- scan("https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt", what = character())
dictBig <- dict[nchar(dict) > 10]
consonants <- letters[!letters %in% c("a", "e", "i", "o", "u")]
#The following line is equivalent to sapply(consonants, function(x) stringr::str_count(dictBig, x))
#As with all things with strings in R, life is easier with stringr or stringi.
consonantCount <- sapply(consonants, function(x) lengths(regmatches(dictBig, gregexec(x, dictBig))))
wordsWithNoRepeatedConsts <- dictBig[apply(consonantCount, MARGIN = 1, function(x) all(x <= 1))]
uniqueConstCount <- rowSums(sapply(consonants, function(x) grepl(x, wordsWithNoRepeatedConsts)))
biggestWords <- function(offset) wordsWithNoRepeatedConsts[which(uniqueConstCount == max(uniqueConstCount) - offset)]
cat("Biggest:", paste(biggestWords(0), collapse = ", "),
"\n \n Second biggest:", paste(biggestWords(1), collapse = ", "),
"\n \n Third biggest:", paste(biggestWords(2), collapse = ", "))</lang>
{{out}}
<pre>Read 25104 items
Biggest: comprehensible
Second biggest: administrable, anthropology, blameworthy, bluestocking, boustrophedon, bricklaying, chemisorption, christendom, claustrophobia, compensatory, comprehensive, counterexample, demonstrable, disciplinary, discriminable, geochemistry, hypertensive, indecipherable, indecomposable, indiscoverable, lexicography, manslaughter, misanthropic, mockingbird, monkeyflower, neuropathology, paralinguistic, pharmacology, pitchblende, playwriting, shipbuilding, shortcoming, springfield, stenography, stockholder, switchblade, switchboard, switzerland, thunderclap
Third biggest: acknowledge, algorithmic, alphanumeric, ambidextrous, amphibology, anchoritism, atmospheric, autobiography, bakersfield, bartholomew, bidirectional, bloodstream, boardinghouse, cartilaginous, centrifugal, chamberlain, charlemagne, clairvoyant, combinatorial, compensable, complaisant, conflagrate, conglomerate, conquistador, consumptive, convertible, cosmopolitan, counterflow, countryside, countrywide, declamatory, decomposable, decomposition, deliquescent, description, descriptive, dilogarithm, discernible, discriminate, disturbance, documentary, earthmoving, encephalitis, endothermic, epistemology, everlasting, exchangeable, exclamatory, exclusionary, exculpatory, explanatory, extemporaneous, extravaganza, filamentary, fluorescent, galvanometer, geophysical, glycerinate, groundskeep, herpetology, heterozygous, homebuilding, honeysuckle, hydrogenate, hyperboloid, impenetrable, imperceivable, imperishable, imponderable, impregnable, improvident, improvisation, incomparable, incompatible, incomputable, incredulity, indefatigable, indigestible, indisputable, inexhaustible, inextricable, inhospitable, inscrutable, jurisdiction, lawbreaking, leatherback, leatherneck, leavenworth, logarithmic, loudspeaking, maidservant, malnourished, marketplace, merchandise, methodology, misanthrope, mitochondria, molybdenite, nearsighted, obfuscatory, oceanography, palindromic, paradigmatic, paramagnetic, perfectible, phraseology, politicking, predicament, presidential, problematic, proclamation, promiscuity, providential, purchasable, pythagorean, quasiparticle, quicksilver, radiotelephone, sedimentary, selfadjoint, serendipity, sovereignty, subjunctive, superfluity, terminology, valedictorian, valedictory, verisimilitude, vigilantism, voluntarism</pre>
 
=={{header|Racket}}==
331

edits