Find words which contain the most consonants: Difference between revisions
Find words which contain the most consonants (view source)
Revision as of 12:44, 5 September 2021
, 2 years ago→{{header|Racket}}
(→{{header|jq}}: two subtasks) |
|||
Line 1,368:
347 most consonant words: {{9,"comprehensible"},{8,"administrable"},"...",{4,"bourgeoisie"},{4,"onomatopoeia"}}
</pre>
=={{header|Racket}}==
<lang racket>#lang racket
(define (consonant-count s)
(set-count (set-subtract (list->set (string->list s))
(set #\a #\e #\i #\o #\u))))
(define words-by-consonant-count
(group-by consonant-count (file->lines "../../data/unixdict.txt")))
(module+ main
(define group-count (compose consonant-count first))
(define group-with-max-consonant-count
(argmax group-count words-by-consonant-count))
(displayln "Group with gratest consonant count:")
group-with-max-consonant-count
(printf "with: ~a consonants in each word"
(group-count group-with-max-consonant-count)))</lang>
{{out}}
<pre>Group with gratest consonant count:
'("bremsstrahlung" "comprehensible" "crystallographer" "crystallography" "electroencephalogram" "electroencephalography" "handicraftsman" "handicraftsmen" "immunoelectrophoresis" "incomprehensible" "knightsbridge")
with: 9 consonants in each word</pre>
=={{header|Raku}}==
|